For example if you are battling 5 enemies do you line up 5 troops so troop in slot 1 has strength against first enemy, troop in slot 2 strength against second enemy etc?
No you better don´t do that. Honestly the best thing you can possibly do at your stage is to ALWAYS use 5 of the same unit. Whichever one is good against most of the enemies.
The units don´t fight 1 on 1 they fight 5 on 5. The AI is not especially intelligent, so it does not use each units advantages at all. It just picks one enemy and then send all your troops against that one (if possible, if not possible it will pick a secondary target etc). The enemy does the same.
So The best thing you can do is pick 5 of the same that way you have an advantage against most enemies and the enemy has few advantages against you. You will lose a few troops but you will win the fight.
Another reason to use 5 of the same is they are equaly fast and therefore are able to fight together. if you mix fast and slow troops, your 2 or 3 fast troops will run forward and fight 5 enemies, get killed quickly and then the slow ones show up and again fight 2 or 3 against 5. Never a good idea. if you use 5 of the same you can force the enemy to make exactly that mistake (because they often mix troops)
As an example the enemy has 2 LM (light melee), 1 HR (heavy range), 1 LR (light range), 1 HM (heavy melee)
You would use 5 HM (treants or Paladins depending on your race) In the beginning of the fight his LR unit will kill a bunch of your HM, but as soon as your HM catch him and beat him up together you´re good, the rest of the fight will be easy going for you. You will quickly kill off the LM and HR and the slow walking enemy HM may not even enter the battle until it´s half over.
Then how does this play out for some provinces where you have 8 enemies but only can bring 5 troops to the battle?
No difference at all. You just have to fight 5 against 8. Sounds worse than it is though, because if they are 8 squads, they are usually 8 smaller squads, so total enemy numbers are the same, just split up into more groups.