After an attack was ordered, and soldiers went over-the-top, crossed no-mans land and were able to successfully clear and occupy the enemy trench, what happened next?
Did that newly taken trench become the attackers new front-line trench, pushing no-mans land back?
I'm having trouble picturing how this worked, considering there were several lines of trenches on each side, and they went on for hundreds of miles from Switzerland to the North Sea. I know that the front line moved very little in this war, but it seems unlikely that it would even move at all with both sides dug in like they were.
There's no one answer to this, as it would depend on the nature of the attack, the wider objectives for that sector of the front, the ferocity of enemy counter-attack, and the tenability of that stretch of trench with regards to the local terrain (was it a death-trap enfiladed by another enemy-held trench or strong-point, for example). The attackers might fall back with their immediate objective completed, they might hold and improve the trench they have just taken, or they might push on (or alternatively, the men who had taken the trench would stop and the next wave of attackers - fresh troops - would pass through their line and take up the assault).
The nature of the attack is the big one. An attack on a trench was not necessarily part of a 'big push' that stretched for miles and involved vast numbers of troops. Units were constantly engaged in what was called 'smack and back': in other words, small scale trench raiding (Haig called it "Winter sports" in his diary of January 1916, and felt it a vital element in keeping up aggression, momentum and fighting spirit in troops stuck in a static line; they were also referred to as 'Minor Enterprises' in notes issues by General Staff GHQ in March 1916). This involved a relatively small number of men (from a handful to hundreds) crossing no-man's land, attacking the enemy line, then retreating.
It might take place under cover of darkness, with a few men armed with trench clubs, grenades, knives and pistols crawling to the opposing line, their identification removed, their faces blackened; freezing when the Very lights and star shells lit up the landscape; holding their breath praying the enemy sentry was half-asleep; snipping through their own and the enemy wire; and then dropping into the trench, fighting vicious hand-to-hand struggles, bayoneting, coshing, slinging bombs down dug-out steps. The aim here would usually be intelligence gathering, and the prize was dragging a few stunned and often severely beaten prisoners back with them for interrogation at Brigade HQ. A larger company-size raid might take place under cover of a sudden box barrage from the artillery, and use surprise and overwhelming violence rather than stealth and darkness to achieve the aim. With raids the enemy trench was cleared and occupied, but only briefly, just long enough to achieve a certain goal.
The German trenches have been entered by patrols of from 2 to 8 men, and for the purpose of securing an identification or obtaining information on some definite point, e.g., the existence of a suspected mine shaft. GHQ Notes, March 1916
Even the smallest such raid was (ideally but not always) meticulously planned, making use of aeroplane photographs, patrol reports, prisoner statements, trench log books, and reports from snipers and artillery forward observers.
Larger actions (but still not huge, sweeping, strategic pushes intending to take miles of ground) might be ordered to seize a local strong-point or troublesome enemy position. This might be a battalion or divisional effort (involving several hundreds to a few thousands of men), and I guess this is the main focus of your question. Say the requirement was to clear a section of the enemy line that was problematically close to their own and tactically useful. How would they take and hold a trench in this case?
First comes the artillery. There might be an initial bombardment to 'soften' the line and a creeping barrage to cover the attack with a curtain of fire. But the artillery would also play a defensive role by isolating the fighting area - hitting the flanks and rear areas, including communication roads and trenches, to stop enemy reinforcements from moving up, and using counter-battery fire on the enemy artillery to suppress it.
Assuming the initial infantry attack is successful, and there's no intention (or reasonable hope) of pushing on further, work now begins to fortify. Designated blocking parties work left and right down the traverses and fire bays with bomb and bayonet, securing the flanks of the attack. Lewis guns (light machine guns) might be set up to cover, along with well-supplied bombing parties to defend, and pre-prepared trench blocks made of wood or iron pickets and barbed wire put in place to hinder enemy counter-attacks back down the trench line. Now desperate work would begin to reverse the parapet (front of the trench) and parados (the rear). Sandbags would be thrown up or pulled down as necessary, field of fire improved, a fire-step cut if need be. Labour parties would begin cutting communication trenches back towards the friendly front line. Ammunition and supplies are brought up and the attacking troops relieved if possible. So essentially, the trench facing has been reversed and (ideally) connected up to the attackers existing trench system, and now acts as both strong-point and a jumping-off point for further attacks.
The enemy meanwhile will likely be attempting to counter-attack and seize the trench back. Depending on the geography they may be very close; as you say, there were several lines of trench behind the forward fire trench that has just been taken: the supervision trench, the support and reserve lines, a labyrinth of communication trenches with associated cover trenches alongside, and in an area that had been fought over for a long time there might be whole networks of abandoned trenches, saps and other earthworks in between that could be reoccupied. If the enemy were too close efforts might be made to dislodge them, or an uneasy peace might descend for the time being, with opposing troops dug in just yards away from each other, exchanging anything from shouted insults to rifle-grenades depending on the aggression of the units involved and the pace of the local fighting.
So to directly answer your question, in such situations yes, the newly taken trench would become the attackers' new front line, perhaps temporarily while the attack continued, perhaps for many months. No-man's land was pushed back, but not necessarily very far at all, because the enemy's new front line might be just yards away in their former support trenches. These small, bloody, incremental pushes by companies, battalions and divisions were the terrible, largely forgotten day-to-day business of WW1.
Main source: An Officer's Manual of the Western Front, compiled by Dr Stephen Bull, which includes sections from Infantry Training, 1914 and Manual of Field Engineering, reprinted 1914