This is from an earlier clarification from the fantastic Moderator Silmeth:
Historically it used to be an, but then this an started to be pronounced differently in different contexts, /ən/ by default, but /əm/ before bilabial sounds (like /m/ or /p/), and just /ə/ before fricatives from lenited consonants.
And today it’s written accordingly in those contexts. So you write am before f, b, m, and p, and a’ before lenited consonants mh, bh, ph, gh, ch, and an otherwise (before vowels, including vowels after lenited fh: an iuchair the key, an fhìrinn the truth; and before all other consonants: an sgeul the story, an t-sràid the street, an cat the cat…).
Further in my notes (most definitely paraphrasing Silmeth or other advanced speakers here!): A' is applicable only before feminine nouns whose initial consonant is a lenitable labial (lip sound) b, p, m and f or a velar (back part of mouth) e.g. c or g.
Its still early in the course for you and gets explained later on. Essentially, a word may get changed after the definitive article (it undergoes lentition....a softening of the sound). The definitive article is 'the' or in Scottish Gaeilic (an / am / a') which all mean 'the'.