If you want to make some ground an attacking army has to cross the trenches, and because you now have machine guns the defending soldiers could sit behind their trenches and mow down the attacking army, very easily.