First of all, only the western front was locked in trenches in ww1, and to some extent the Italian front. The eastern front, the serbian front, the Palestinian front, the Kut front etc all moved quite a bit back and forth.
Secondly, the reason the front stagnated between autumn 1914 and spring 1918 was mainly due to the concentration of artillery - no where else, before or after, have such an concentration of artillery per km of frontline been achieved over a large front. Another reason was the advantage of mobility of the defender - artillery had a limited reach. As soon as the forces breaching the frontline reached the position beyond their own artillery's reach, the encountered a new line covered by enemy artillery. It was quick to move reserves by rail to a threatened front, while reinforcements for the advancing party had to move over the devastated no-mans-land. Especially artillery and its supplies was hard to move this way.