At each round a unit will check it's target and attack the primary target. If that changes, they'll switch their target.

In other words, they'll attack ponies while they're in range, but when archers come into range, then from the next turn onwards they'll attack the archers.
Once all the arcehrs are dead, they'll re-asses their targets again.