In this scene Malcolm is approaching Dunsinane at the head of an army of some ten thousand men. He gives the following order:
Let every soldier hew him down a bough
Amd bear 't before him. Thereby shall we shadow
The number of our host and make discovery
Ere in report of us.
Each soldier will be carrying one branch, not cutting down any trees. But with so many men carrying branches the effect will seem like a moving forest. Macbeth intends to remain inside his castle with his forces and make the invaders lay siege, as he says in the next scene:
Our castle's strength
Will laugh a siege to scorn. Here let them lie
Till famine and the ague eat them up.
But when the Messenger reports that he thought he saw Birnam Wood moving towards Dunsinane, Macbeth changes his mind and orders his soldiers to go out to meet them. This is probably because he believes the approaching army to be larger and better equipped than he had anticipated. Macbeth had felt assured by the witches' Third Apparition in Act 4, Scene 1 that he could not be overcome until Birnam Wood moved to Dunsinane.
Macbeth shall never vanquished be until
Great Birnam Wood to high Dunsinane hill
Shall come against him.
When this is exactly what appears to be happening, Macbeth is appalled. He becomes panicked and desperate. He loses his ability to think clearly and to use his experience as a soldier to plan the best defense against the coming assault. He no longer feels psychologically capable of patiently withstanding a siege that could last for months. He repeatedly calls for his armor. He wants to get the fighting over with, regardless of the consequences and regardless of the fact that he has lost many soldiers and thanes through desertion.
Malcolm, of course, had no idea that his order to cut down the branches would have any special significance to Macbeth, but it has a devastating psychological effect and helps to bring about a quick victory.