yeah, defending - but there must be other conditions as well - I have only seen it once so far
Your army must be dug in, ie it must have been in the same spot on the campaign map for 1 turn without moving and have the wooden stakes shown around it. If this is the case and you are attacked you get the chance to build defences.