Furthermore, when they did defeat Hannibal they had more cavalry, yes, but it was not Roman, it was Numidian cavalry. Proper Roman cavalry was simply not that spectacular. Hannibal lost his most important edge, if not the only one, against the Romans, because his infantry simply were no match for the Roman ones.
The battle of Zama is not nearly as simple as you make it out to be. Hannibal and Scipios first and last confrontations were bloody. The Carthaginian cavalry was out matched so it pulled the Roman cavalry off the field in hopes that it wouldn't attack the Carthaginian infantries rear.
This worked for a time so during the melee Carthaginian Mercenaries and citizens fought the Roman Hastati, Principe and Triarii. However even though he Romans are said to have this innate superiority they didn't crush Hannibals mixed green and veteran troops instead until the Numidan cavalry came back to attack Hannibal rear it was a stalemate.
In terms of their political system: they had many more inferior generals than they had good ones. For every Scipio africanus, Sulla/Marius or caesar they had a handful of servilius capios' - and they still managed to succeed.
Every single major Roman conquest was done by a successful generals, those that were mediocre managed to win or lose a few battles or wars yet the major conquests such as Iberia, Africa, Egypt, Gaul, Greece, Syria and more were made by successful generals.
You simply can not make a military system that is so good mediocre generals can beat better ones. The Romans for their part were able to create a series of tactics and a military system that didn't require a genius to use however their actual success came from skilled and experienced generals that most states did not have. A comparable point in history would be Alexander's Empire filled with competent and experienced generals however unlike Rome they had no reason to be loyal to the state even as a few tried to hold it together.
I think this is the key point. Alexander was nothing without his cavalry, that was what won battles. The anvil is nothing without the hammer. Phalanx sans cavalry will be easily flanked and destroyed.
The idea that the Macedonian army consisted of just a phalanx needs to die in a fire. Macedon under Phillip and later Alexander created the first all professional combined arms army. They had a small core of Phalangites that made up the center line, a large number of Hoplites that would protect the flanks and peltasts for skirmishing before battle and able to join in the melee during the fighting. They had various types of cavalry such as the Thessalians able to both skirmish with javelin and charge somewhat effectively they were likely the most famous Greek cavalry until Alexander's Hetairoi companions. There were also the various light cavalry contingents such as the Prodromoi scouts meant for exactly that scouting before battle and protecting the right flank or the 2,000 strong cavalry contingent supplied by the Peononans and Thracians. Alexander even had a regiment of Sogdian (or Scythian I cant remember at the moment) horse archers which famously caused disorder in the Indian ranks during the battle of Hydaspes with sustained volley fire.
For example at Guagamela the most famous of Alexander's battles his 47,000 strong army had a whooping 9,000 Phalangites in an army that had 31,000 heavy infantry that's quite a bit but only a third of the heavy infantry in the army the rest being Hoplites or Hypaspists. Mind you this is the same battle where the Persians encircled the Macedonian left flank and were attacking it from all sides yet failed to break Permenion's men before Alexander arrived after knocking Darius off the field.
So much for simply flank the phalanx.