I'm thinking perhaps the count of how many units in the group is not updated until the leader notices they're dead
You're right. It takes some time for the dead people get removed from arrays and count command doesn't check wether the unit in array is dead or alive.. it just counts him as one.
You could pharhaps consider another way of doing it?
#reset
_counter = 0
_grp = enemies1
_max1 = count enemies1
_max2 = count enemies2
_allmax = _max1 + _max2
#check
?!alive (_grp select _counter): _allmax = _allmax -1
?_allmax < 5: goto "continue"
?_counter == _max1: _grp = enemies2
?_counter == _max2: goto "reset"
_counter = _counter +1
~0.1
goto "check"
#continue
I'm probably showing you the most difficult and complicated way, but I'm very sleepy at the moment. Have a go at it and see what it does.