I'd split the attacks and the follow, into two different macros.

If you press an attack key, and nothing is targeted, the warcraft default action is to target the closest hostile.
That assumes there is a hostile, within a relatively small area.
Not sure on a workabout to prevent this, as its a game default.

Possibly go with a Target=TargetTarget system.
Where the slaves target the master always.
And then cast at the Master's Target, via Target=TargetTarget macros.

Still, if you press the attack macro... and a hostile is there, then the slaves will probably attack it the same as normal.
But with separate follow and attack macros, follow should not cause a flagging attack.