The main answer for this is that " the attack ran out of momentum". Maybe I have a fundamental misunderstanding of how trench warfare worked, but I assume that once the enemy's trenches were broken through, it would be much easier from that point onward to gain ground.
You're absolutely right, but you're forgetting an important factor.
As the attacker advanced, he was moving toward the enemy's undamaged transportation and communication network. Meanwhile, his own transportation and communication network was broken by the trench lines he had captured.
That meant that the opponent could bring in reinforcements much more easily than the attacker could bring in additional soldiers and supplies to exploit the breakthrough. That's what it means when an attack "runs out of momentum." The opponent has had time to react to the attack, seal off the penetration, and stop the advance.
Now, by the time of the Second World War, aerial bombardment technology had advanced to the point that it could interdict a defender's supply and reinforcement routes. One of the most famous examples is the redeployment of British and American strategic bombers from targets in Germany to targets in France in the month preceding the Normandy landings.
The disruption of the French rail network (as well as Hitler's belief in a second landing) prevented German forces from reacting to the landing as quickly as they otherwise might.
Of course, once Operation Cobra took place and American forces broke out of Normandy, the shoe went on the other foot. The disruption of the French rail network meant Allied Forces were the ones who had supply troubles, and their attack ran out of momentum almost exactly at the German border, allowing German forces to stiffen their defense and muster a counterattack, just as had been done on a much smaller scale 28 years before.
The problem had not changed, only the scale ...
So the thing you need to understand is how effective wired-in trenches were for the defensive.
The trench itself renders the defending infantry virtually immune to small arms fire, and immune to all but a direct hit from artillery. The wire prevents attacking infantry from closing with the defenders who can then pour fire into the exposed attackers, who, being in the open, are lambs to the slaughter for the defending artillery.
So in order for an attack to succeed it needs to be preceeded by a bombardent, the purpose of which is to
This takes a lot of bombarding. It takes a lot of artillery to do this successfully and this was the defining characteristic of the war. The upshot of all of this was
Impossibility of achieving surprise: Before the advent of predicted fire, each gun had to be individually registered. Not only does this take a long time (at Loos, it took three weeks to register the guns, and that was a small battle), it also makes it pretty damn obvious to the defender where the attack is going to fall. The defender can therefore direct reinforcements to the menaced sector to contain any break-ins and prevent a breakthrough.
Lack of communication: The need for any side to be constantly underground renders line-of-sight communications (semaphore, heliograph etc.) useless. Voice commands are obviously no use as an infantryman in the enemy trench can’t simply yell for artillery support. Radios do exist but are fragile, primitive and cumbersome. Telegraph and telephones exist but the cables are constantly going to cut by artillery fire. This leaves only runners, riders, and carrier pigeons as viable communications. Thus if the attackers come across a strong point and are held up, they can’t summon any supporting fire or reinforcements and they can’t ask that the barrage be retarded or advanced. Later in the war, the advent of SOS rifle grenades and air-ground co-operation somewhat mitigated this, but the problem was not solved until the advent of man-portable radios in the next war.
More importantly than all of this, the Generals were powerless to actually direct a battle once it had commenced. They could plan the initial stages to the last detail, but after that they would just have to stand there, trying to piece together just what the hell was going on by a flurry of bits of often contradictory information from runners, riders and animals, along with the odd bit of electronic information.
The problem was recognised and lead to what was known by the British as ‘Bite and Hold’. This was a purely attritional strategy in which the aim was to break into the enemy line, hold it, and smash up his counter-attacks, thereby inflicting greater casualties on them than they had suffered themselves. This type of battle reached its epitome during 3rd Ypres and could be devastatingly successful in the right circumstances.
Lack of any means of exploitation: Traditionally, exploitation and pursuit was the job of the cavalry, however wire and machine guns meant this was no longer practicable. Note that this does not mean that cavalry and mounted infantry were useless in WWI, just that they could no longer achieve their traditional role with very great efficacy. The introduction of the second generation of fast(er) tanks like the Whippet helped to solve this problem, and eventually armoured cars would be used to some effect, but this was very late in the war.
Operational Temp and logistics: So, imagine you are a general and you have smashed your way into the enemy lines successfully. Now what? Not only do you need to establish a supply chain over no man’s land, your infantry are going to be at the limit of your artillery’s range. So now you need to move your entire war machine another step forward and this takes time – time in which the enemy will be consolidating and re-building his positions.
So maybe attack somewhere else? OK, but now you have to move all those men, all those guns, all those hundreds of thousands millions even of shells, tons of food, fodder, water, medical supplies etc. to a brand new sector and start the whole bloody circus up somewhere else.
This is no mean feat of logistics and it was only by pretty late in the war that the armies became sufficiently competent to keep this kind of thing up.