Why did the Persian army lose the battle of Marathon?

Persian army was an absolutely massive army,and persian empire defeated famous empires such as babylon using it, you know that then Greece wasn't a united country and it was built from different city-states,so naturally it doesn't have a well trained and united army,and Persian army was at least 200000 man large,so why was it defeated and why was it retreated from Greece land after it?(note:I'm not a professional historician or something else,so do not expect me to ask professional questions.I'm just a twelve year old student who is trying to learn )

Marathon was won because ordinary, amateur soldiers found the courage to break into a trot when the arrows began to fall, instead of grinding to a halt, and when surprisingly the enemy wings fled, not to take the easy way out and follow them, but to stop and somehow come to the aid of the hard pressured centre Lazenby, J.F. The Defence of Greece 490-479 BC. Aris & Phillips Ltd., 1993 (ISBN 0-85668-591-7) as cited in Wikipedia

The question proposes "… naturally [Greece] doesn't have a well trained and united army… " - assuming that a nation is required for a trained army. I do not agree with that assumption. The Greek city states fielded armies that were well trained and well equipped. Greek armies could fight in the phalanx; any dense military formation requires fairly intense training. (despite the claim that the hoplites were "amateur".)

I cannot say for sure, but the following points seem relevant to me.

The Persian infantry was evidently lightly armoured, and no match for hoplites in a head-on confrontation.

The Persians knew that in a face to face slugfest, the hoplites were better armored; Persian strategy relied on decimating the hoplites with arrow fire before that face to face engagement. The Greeks denied that strategy; they charged. They accepted the losses from arrow fire to close to personal combat. All combat involves the courage of the participants and the Greeks demonstrated their courage to the Persians.

In order to face the Persians in battle, the Athenians had to summon all available hoplites;[34] and even then they were still probably outnumbered at least 2 to 1.[38] Furthermore, raising such a large army had denuded Athens of defenders, and thus any secondary attack in the Athenian rear would cut the army off from the city; and any direct attack on the city could not be defended against.

To quote Sun Tzu, "Verse 5. If you are anxious to fight, you should not go to meet the invader near a river which he has to cross." The Greeks knew that they were the last line of defense - there were no more hoplites to be summoned. This engagement was the only opportunity to save their cities, their families and their posterity. If they lost here, all was lost; they were fighting with their back to a river. The Persians did not and could not bring that level of commitment to the fight. Defending forces with their back to a metaphorical river are difficult to break.

In war, moral power is to physical as three parts out of four. Napoleon

The Greeks had the moral power (morale) arising from their lack of alternatives. The invader has the option of retreat; the defender must win.

Skilled military historians might cite position on the field of battle and supply lines/logistics. But for me, the reason the battle comes down to us in history is the courage of simple soldiers to charge into artillery fire, demonstrating that they were not just willing to die for their country, but to die in order to bring death to the enemy.