Answer :
'An' in german can be differently used. It can be suffix in verbs, like Das geht Sie nichts an! (verb: andenken), but also it can preposition like: Ich schreibe an die Taffel oder das Bild hängt an der Wand. In those two sentences it means at or on. In first two sentences that you wrote it is about verbs with preposition like denken an + Dativ 'think of'.