Auto resolve does not take into account unit positions. If you look at the details screen it will show units moving towards each other, but at no point in the battle will they stop when reaching other units, they simply pass straight through them to their target (which is always the unit with the least defense). Secondary is that ranged units do not attempt to kite in auto-resolve, but do attempt to kite in auto-play.
The solution to this would be to seperate melee units and ranged units before attempting the calculation. Ranged units always attack the units with the lowest hp/defense and always use their turns to move further away. Each melee unit is capable of blocking up to 3 other opposing melee. Up to 3 melee attacks can be made on a single target, starting with the melee target with the lowest defense/hp. If one side is outnumbered by 2 times or more only one attack can be made against any one target each round.
For every movement speed higher than 2, that unit counts as an additional 1/2 unit for the purposes of blocking to a maximum of 3 (thus making units with move speeds of 6 or more require one unit each to block). Units that are not blocked can make up to 3 additional attacks (total of 6) against any one target and recieve a higher priority for any present ranged units.
To put this in perspective, Let's say an army has 3 archers and 3 melee against another army with 3 melee and 3 (3 move) horsemen. Each sides units make their moves and the archers fire at the lowest defense units. The melee then meet in combat. Since there are 3 melee on side 1 they are capable of blocking a total of 9 units. The value of the opposition against them is 7.5, and thus they can prevent all of the enemies from reaching their rear line. However since they are outnumbered they must spread out to accomplish this and can only strike each opposing unit a maximum of 1 times. Side 2 is not subject to this restriction, and can make 3 attacks against each melee target (starting with the lowest hp/defense). The situation may change if units die on either side.
If in the above case, side 1 instead had only 2 melee, units could break past their lines starting with the fastest/lowest attack units first. In this case a horseman (probably) (worth 1.5) would break into the rear lines returning the value to 6 and enabling the melee to block the rest. Depending on the offensive/defensive value of the horseman (compared to other units on the battlefield) the archers may all switch targets to that unit.
To provide another example. Lets say you attack a shrill lord with your melee champion and a ranged champion. In auto-resolve that ranged champion is almost certain to die, but if you played out that battle you would likely walk away unscathed. The reason for using the lowest attack/highest speed unit is that if that shrill lord (while faster) was even looking in the direction of your ranged champion, you would have your melee champion intercept and let the slower less threatening shrills bypass your zone of control. There probably needs to be some weights attached to the value of a units attack/defense and hp value to properly work this out, but even just making melee stop to fight other melee until they die would be a step up from the current method of caculation.