Good question!
It's because phonologically they begin with a consonant, not a vowel. These words are pronounced as if they had a 'y' sound at the beginning (Yuniversity, yuniform etc). You don't say 'an year', so you don't say 'an (y) university;' either - you say 'a university'.
Many people don't realise that the a/an distinction is to do with pronunciation, not spelling.That's why we say 'an hour' and 'an honour' - these are words which are written with an initial silent consonsont, so they are pronounced with an initial vowel sound.