Ah yes, this design decision again. Making both sides attack a random enemy, instead of any kind of pattern. So win/loss depends 100% on targeting RNG. Love that.
There is actually a certain system for targeting. Right now, I haven't decided yet on how to explain it to the player, or whether I should even.
Basically, when the units are choosing the target, it always picks the unit in range that was attacked the least amount of times this turn.
This means, for example, that if the infantry attacked the front-most unit, the cavalry behind would avoid it and attack units in the back. This allows for some planning and strategy.
Although it does not remove the randomness factor completely, which is a definition of the autobattlers genre at this point.