How to divide units in a war?
To make thing easier, you can divide units based on their reach - close combat and shooters - or the way they move - infantry and cavalry. Artillery in such situation will be considered as infantry, as it has similar speed. Such division makes it easier to place units on battlefield. Infantry should stay back and cover shooters, cavalry should secure wings, and artillery remain completely at the back so that it won't get assaulted by enemies.
Why is it unwise to fight until the last soldier?
Unit experience and rank. The more battles your formation have survived , the more experience he gained. Experience improve formation statistics , which makes even low tier formations useful on the battlefield. It is one of reasons why it is unwise to fight until last soldier and lose a formation.
Can you upgrade units in provinces?
In provinces that have right buildings it is possible to upgrade units. You can upgrade a weapon, separately for melee combat and range combat, an armor and horses, depending on upgraded unit. Upgrades slightly increase statistics of a unit - melee combat, range combat, armor and speed - but can be done up to three times per unit. And they aggregate with experience gained in combat. Because of that, a good tactic is to first upgrade created formations and then allow them to gain experience in combat. Such formations will be much better than newly created ones on the same level.
Is infantry good against cavalry?
Missile units are effective against infantry, infantry works well against cavalry, and cavalry is good against shooters. Additionally, artillery is weak in melee combat, just like other shooting units, but in range combat it can manage very well. It doesn't mean that infantry is useless against archers. Cavalry is simply faster than them. Most of infantry fight well against cavalry because of having pikes and spears.