... They also used a medium sized spear and a rectangular shield. In spite of what the movies show, the gladius was used only when you lost your spear, which was looked down upon.
Throughout the history of the Roman army, the pilum was the primary spear used by the legionnaire. It was designed as a throwing weapon, and not a thrusting one. Using a soft iron point, about two feet long mounted on a four-foot wooded shaft, it was barbed and designed to penetrate a shield, and then bend, rendering the shield useless. It also penetrated leather armor rather easily, and was impossible to pull out of flesh without tearing. It was weighted at the junction of the point and shaft, causing it to tip over on flight, and carry a great deal of momentum and attack angle.
Most hastati carried two, and used them very effectively.
After closing in, the legionnaire relied on the short Gladiolus Hispanicus. They were drilled constantly on using it as a thrusting weapon. Legionnaires were punished for turning to slashing methods. The sword was carried on the right side, eliminating the possibility of an enemy jamming the shield against the legionnaire's body, preventing drawing.
The shield was used to parry the swing of swords, axes, etc., allowing the legionnaire to close and thrust toward the midriff area of the enemy.
It's relatively easy to parry a swinging move, regardless the weapon. The swing arc of the longer sword, battle axe, etc., are telegraphed very easily by the user; and any swinging motion opens up the body to a thrust.
It's almost impossible to parry a short thrust from behind the shield, especially when protected by the shield on the legionnaire's right. Each position in the line protected the legionnaire's arm to his immediate left.
About the time of Marius' changes, the triari, or third liners, changed from a heavy spear designed for thrusting, to the standard pilum.