A or an is used as an indefinite article, usually followed by a singular countable noun.
A is used when the next word begins with a consonant.
An is used when the next word begins with a vowel sound.
When a word begins with the letter 'u' that is pronounced /juː/, the word is treated as starting with a consonant: a university.
When a word begins with a silent 'h', it is treated as starting with a vowel: an hour.
The names of the letters f, h, l, m, n, r, s, and x begin with vowel sounds, so abbreviations that begin with one of these letters are treated as starting with a vowel: an MP ♦ an HGV.