>After a few weeks of marching and countermarching by Philip and Flamininus in central Thessaly, battle was joined (almost by accident) at Cynoscephalae, hills known as The Dogs’ Heads. Invincible on flat ground as long as its flanks were protected, the phalanx was dangerously exposed on hillsides. Highly manoeuvrable, veterans of the Hannibalic war, the legionaries wreaked a terrible slaughter.
One of the big factors at Cynoscephalae and later at Pydna was the extreme flexibility and how much initiative junior officers had. At Cynoscephalae, the turning point of the battle came when a junior Roman officer saw that one of the halves of the phalanx was still forming up, and immediately sent Roman units against that unready part of the phalanx, routing them, and then crashing down on the rear of the other part of the phalanx that was actually winning against the Romans. At Pydna, Lucius Aemilius Paullus the Roman commander was able to give the general order to exploit the gaps, and let the various unit commanders implement it.
The combination of Roman training combined with the tactical flexibility stood Rome in very good stead for centuries.
As an aside, it is not necessarily the unit, but the commander who knows how to put it to great use that matters. Alexander the Great used an army of which the core was the phalanx to win battles over many, many types of terrain. He knew how to use the phalanx well in combination with calvary and light infantry to devastating effect.