'An' is used before a word starting in a vowel or certain word beginning with "H". For example, it used to be "an hotel", however, "an" before an "h" does seem to be falling out of use.
'A' is used otherwise.
Your example sounds more correct because when you are pronouncing the "m", you are effectively inserting an "e" before it. Technically, "a" is right as "m" is a consonant. However, no-one is going to complain if you say an "m".
Ian (Mackem_Beefy)