Obviously we know the two way prepositions.
Es liegt auf dem Tisch - It is on the table
Es wird auf den Tisch hingelegt - It is being placed on the table
Dative for something that is already in the place of destination. Accusative for something that is traversing towards place of destination.
However for an there seems to be an issue:
Er hat etw an der Wand befestigt
Er klebt das am Tisch fest
This does not comply with the two way prepositional rule, it is not already sticking to the table it is in the process of being stuck on yet it takes dative. Can someone explain why?