Using A-move, how does the system determine which enemy unit is attacked by a given unit? I understand that it might attack based on which unit enters its attacking range first, but what if two units enter simultaneously? Or a major battle is going on, and after killing the enemy unit it is attacking, what determines the next enemy unit that is attacked by a given unit? Is this random or simply attacking the nearest unit from the ones in range, or is there an order/rules for this?
Yes. There is priority. If you go on starcraft.wikia.com, and search up a unit, it will say at the bottom of its stats: "Meta". In the Meta group, there will be "target priority". For example, the spore crawler has 19 Priority. Beyond priority, I believe that distance plays a part. Also, I believe there is a trigger in which, if you target an unit, that unit can choose to attack you, and etc.