Trench warfare arose when there was a clear advantage to the
defense in the form of
warfare both sides were using. Armies advanced until they reached contact, at which point neither one would be able to 'break through' the other's defenses. In times before
industrial warfare, the favored tactic was to
flank the enemy; whichever army could move
laterally more quickly had a decent chance of surrounding or at least
evading the frontal prepared defenses of their opponent. However, with the enormous militaries of the
Twentieth Century and the ability to
supply them (
railroads), it became possible for both sides to simply extend their frontage to either side to prevent
encirclement until the fronts ran up against a natural obstacle like, say, an
ocean.
The Germans, in World War I, firmly believed that the way to deal with trench warfare was to innovate around it. Both sides tried numerous tactics (usually initiated by the Germans) such as tunnelling, infiltration, artillery bombardment (this was an American favorite) to get past enemy trench fortifications. Not much helped, however, until the British advent of the tank. This came late in the war, when economic collapse was swiftly closing in on the Germans, and in any case the British didn't figure out how to consolidate the gains their tanks could make before the war ended.
The primary factor determining the location of the 'start line' trenches in World War I, other than the advance rates of the various forces, was the distance to the nearest railhead where supplies and reinforcements could be shipped in. Armies couldn't venture more than perhaps a couple of days walk from a railhead, because pack animals wouldn't be able to make the trip without carrying nothing but feed, and mechanized transport at the time was extremely unreliable.