Roman soldiers were known for using the gladius and javelin as their main weapons, using spears more during early periods and near the fall.
My question is: How did Roman armies defeat mostly spear-wielding enemies (especially since the spear has many advantages compared to the sword)?
The important factor here is not the individual soldier and his equipment but the way the soldiers were organised and used as a whole. Rome employed a standing army of professional soldiers who were well trained and organised to fight as a unit (and those units to fight as part of larger units and so on), whereas many of their enemies were just bands of fighting men.
Once you have a properly organised army you can use tactics and strategies that require a higher degree of planning and discipline.