It’s because the pronunciation is technically a ‘y’ sound, and even though y is sometimes considered a vowel, ‘an’ is not used in front of words that start with the ‘y’ sound.
Explanation:
1. Ramesh asked Imran what he could do for him?
2. The teacher asked Haider Why he had come late to the class again?
3. He asked me Where is the boat? Hurry up we have been chasen.
4. The visitor asked me what is the name of that beautiful beautiful.
5. the painter told me that he had been to the picture.
6. he said that no he had not broken the glass.