That's part of the Hollywood/cartoonish aspect of the movie. The real reason they lost was because the Persians, probably due to treachery, found a pass around the Spartan position and got into their rear.
At Marathon the Persians had no time to deploy their horses. At Platea where the Greeks defeated the Persian land forces after Salamis, they were able to gather a cavalry force good enough to prevent their flanks being turned. Head to head the Persians stood no chance against the heavier infantry.
After that the Macedonian Greeks developed cavalry good enough to allow the Greeks to develop combined arms tactics which allowed Alexander to take over the Persian empire.