Indefinite article is used when you are NOT referring to anything specific.

‘A‘ is used when a noun or adjective starts with a consonant sound.
Consonant is a sound produced when our breath blocked by the lips or when the teeth touch the tongue.

Example : Give me a book.
‘A‘ here is referring to any book. ‘Book‘ here is a consonant.

‘An‘ is used when a noun or adjective starts with a vowel sound.
Vowel is a sound produced when the tongue do not touch the teeth, lips or the roof of the mouth.

Most words start with A, E, I, O and U is a vowel.
Example: An apple a day keeps the doctor away.
‘An‘ here is referring to any apple. ‘Apple‘ is a vowel. Notice that when you pronounce apple, your tongue do not touch your teeth, lips or the roof of your mouth. Only in the middle of the word, your lips touch.