It’s not the definite article here. It is a preposition that in Scottish happens to have the same form as the definite article.
ann an (or ann am) just means ‘in (a)’. Why two words? Because the preposition is repeated, occurs twice. Why? Because of its history.
I am not entirely sure how it came to be but my hypothesis is as follows:
- it comes from Old Irish i (causing eclipsis),
- in Scottish eclipsis was lost, in its place nasal consonant (n or m) appears after vowel: old i / a became an,am, becoming identical to the definite article,
- it made it hard to differentiate the two, so it started to be doubled: ann an instead of simple an (to mean ‘in a dictionary’, instead of older am faclair, one started to say ann am faclair, literally ‘there, in a dictionary’ or ‘in it, in a dictionary’).