As I understand, noun which is singular and start with vowels, we put an article "an" in front of it. ( e.g an eye, an ear )
But why it is not "an earth" and why "the earth"?
You seem to be mixing up two rules here.
We use an instead of a when the next word starts with a vowel sound. Indeed, 'a ear' would sound clumsy, so we say 'an ear'.
We do not use an instead of the; the English have no problem at all saying 'The ice is thick' or 'The ears of a cat are fluffy' (in fact, I would be hard-pressed to find a sentence with 'an ice' in it, since 'ice' is a mass noun).
The distinction between a / an and the is well explained in the other answers.
It does not have to be the definite article (the), even with an "unique object" such as earth or moon. Websites and other sources that say this are either incorrect or giving generalizations. It depends on the speaker's intent whether to make a definite reference (the earth) or an indefinite reference (an earth). This is true even when we are talking about the planet we live on.
An earth without warfare would be preferable to an earth with warfare, some say.
Lucy hopes that global policies are working toward an earth that is healthy rather than an earth that is sick.
An earth with volcanoes, earthquakes and tsunamis is the only earth we have.
If global policies do not change, then by 2055 we will inhabit an earth incapable of sustaining the human race for more than another 100 years.
As for moon, even when restricting our meaning to our moon, we can still use the indefinite article. See my own question on ELU: How on earth can we say 'a moon'?
The question needs more context.
You would use 'the Earth' when 'Earth' is a proper noun, referring to a specific place or thing, the exact planet on which we live. You would use 'an earth' when 'earth' is used more as a pronoun referring to an imaginary or hypothetical Earth-like planet.
The things that are unique (celestial bodies: the Sun, the Moon, the Earth, the Milky Way) take the definite article. However, not all planets take the definite article (just Mars and not 'the Mars'; 'Mercury' and not 'the Mercury').
Worth noting that when the noun starts with a 'vowel', the pronunciation of the definite article is 'dhee' and not 'dhu'
So, it's 'dhu' moon in 'the moon', but 'dhee' earth in 'the earth'.
However, some references say that the article with 'earth' is optional.
Addtiional note: When used as an intensifier, the word does not take any article: Example:
what on earth, who on earth
In addition to the science/science fiction use of multiple Earthlike planets, we can also use "an earth" when we're speaking of soil, as for instance "Thanks to years of applying compost, my garden has an earth that's fertile and easy to work."