just read the units description in the game manual or by clicking on the unit's picture in-game, and you'll see that each troops has bonuses and maluses against at least another one type of troops.
cavalry are particularly effective against archers and swordsmen, even more so in plains where cavlary on both sides gets a +20% to attack.
defend in mountain and you need to have around 2x to "x more spears against the cavalry for it to be effective.
in practice, better for you not to defend agaisnt field battle or pop pilalge attack and instead let your attacker come in a fort siege mode.
with an army 2000 spears + 1000 swords + 800 cavalry (and 200 archers in the fort) ... he won't stand against your defenses
having lots of swordsmen is nice when attacking against empty fort, but it's a liability when your opponent has lots of cavalry
have fun,