"A" becomes "an" before vowels because the "n" makes it easier to pronounce.
an alphabet
an apple
an editor
an empty glass
an incomplete sentence
an indirect question
an opera
an opportunity
an unusual event
an uncommon word
a bag, a cat, a dog, a foot, a game, a hot potato, a job, a kite, a lamp, a map, a name, a pet, a quiz, a room, a seat, a team, a vase, a windy day, a zipper.
Yet there are exceptions. As Dr. B and Nada have pointed out, because "university" begins with the SOUND, "yew," the article before it is "a," NOT "an." One would also say, "A universal rule," "A unitary principle" because the pronunciation of "u" is "yew" in both cases.
In addition, some words that begin with the letter "h" don't pronounce it. For example, "honor," "herb" (in American English).
Because the SOUND is of a vowel (respectively "o" and "e") one should use AN: an honor, an herb.
When the "h" is pronounced (happy, hand), then "a" is used: a happy dog, a handful of grass, a hard test.
How a word is pronounced guides the use of "a" or "an," NOT the spelling.