I have suspected for a while now that the "random" targeting for the archer NPCs (both the enemy and ally variants) isn't actually random and just makes things harder for you, and this was confirmed in a recent game that I had.
Enemy had 15 units, two of which were the Royalist type (which is immune to the first hit they receive from ranged attacks and counterattacks on that first hit). I had a single level two archer unit in my bottom row. IF the formula for calculating the archer's target is actually random, the first time that my archer fired there was a 2/15 chance that it would hit a Royalist that still had its counterattack perk active. It hit a Royalist. Now the second time that the archer fired, there was a 1/15 chance that the archer hit a Royalist that still had its counterattack perk active. It hit the other Royalist. The chance of this happening randomly, given the assumption that each unit has an equal chance to be targeted, is 2/225 or a 0.89% chance.
I don't know if this is intentional but I completely avoid archer units for this reason because these results are typical of my experience playing with them. They're a huge hindrance to your own team, and they're extremely frustrating to deal with on the enemy team because they seem to always attack targets together.