It's mainly down to pronunciation of the word. If one is in the habit of dropping the 'h' then 'an' works in speech.
A hotel, or an 'otel
A historic event or an 'istoric event
The main exception is the word 'hour' which always has a silent 'h'.
Similarly with the letter 'M' which we pronounce with an vowel sound. So you'd have 'a' Master of Art degree, but also 'an' M.A.
I empathise with anyone trying to learn English
