Magruder’s ostentatious movement of troops back and forth convinced the Federals that his works were strongly held. His amateur acting talents were enough to spook McClellan.
That wasn’t the last time that trick worked. The Confederates saved Lynchburg, VA in 1864 by doing similar things; they had extra trains steam into the city and townspeople would cheer loudly as if reinforcements were arriving. Even the local hookers who were, ah, servicing Union clients spread rumors that the Confederates were reinforcing Lynchburg. Eventually the Federals backed off.
}:-)4
The Pinkerton’s troop counting system didn’t help either.