There is a lot in your question and it touches on different topics. Where you are fighting (tournament or world map), chapter you are in, scouting you have done and troops you select all factor in. On the world map some fights are designed to be impossible. I suggest reading my combat guide as a start and ask questions from there.
In terms of the fight position just try to roughly match the enemy. So the first troop is middle and then each one after goes up, then down, then up, then down, etc. If the enemy has 3 heavy ranged then two priests the simplest thing is to match in same locations. So go 3 mages and 2 archers. This will align your troops on the map close o their intended target. 9 times out of 10 this should steer you right. when you understand the up, down approach and they have more then 5 squads then you might occasionally vary things up as they may have stack the upper map section or something.