Use “a” when the following word begins with a consonant sound.
a car (a car)
a dog (a dog)
a house (a house) — The “h” is pronounced (it sounds like a soft “j”).
a university (a university) — Although it begins with a vowel, its initial sound is that of the consonant “y” (/ju/).
Use “an” when the following word begins with a vowel sound.
an apple (an apple)
an elephant (an elephant)
an umbrella (an umbrella) — The “u” sounds like a short vowel.
an hour (an hour) — The “h” is silent, so the first sound is the vowel “o.”
Translated with DeepL.com (free version)