indefinite article before words beginning with vowels, 12c., from Old English an (with a long vowel) "one; lone," also used as a prefix meaning "single, lone" (as in anboren "only-begotten," anhorn "unicorn," anspræce "speaking as one"). See one for the divergence of that word from this. Also see a, of which this is the older, fuller form.
In other European languages, identity between the indefinite article and the word for "one" remains explicit (French un, German ein, etc.). Old English got by without indefinite articles: He was a good man in Old English was he wæs god man.
In texts of Shakespeare, etc., an as a word introducing a clause stating a condition or comparison conjunction is a reduced form of and in this now-archaic sense "if" (a usage first attested late 12c.), especially before it.