Roman legionnairies relied (like their hoplite predecessors in Greece and Macedonia, among other groups) on fairly heavy shields, a decent helmet, and of course, the formation. Those on the outside would fight, then their officers would blow a loud whistle (not makin’ this up) and the soldiers behind would move up. Those retiring would head to the back of the line to rest and wait their next “shift”. These cycles of combat were measured in minutes, and help account for both the effectiveness of the Roman army and for its fairly small size, given the length of the frontiers and extent of the territory.
The Romans also had an advantage in using a stabbing sword as opposed to a slashing type.