Sword Spear units:

If you click to Attack an enemy unit, they charge with their spears but then switch to the swords in hand to hand fighting. If a soldier gets knocked down and stands up again he begins fighting with his spear (thats why you always see some soldiers fighting with their spears while the units attacks with their swords)

If you want them to fight with their spears (against cavalry) you need to alt + click on the enemy.