Let me correct a few errors by others first.
Maxim MGs -- what made these possible was not one German's design, it was the invention of smokeless powder. Before this, all nations used what is today called "black powder", the sort of powder Daniel Boone used for his musket. This powder fouled all firearms and this soon jammed machine guns. So it was smokeless powder that made the difference, and Hiram Maxim or whoever would have invented an MG.
Gas warfare -- this was NOT banned in WW2, that's bullsh*t. Churchill had given orders for mustard gas to be dropped on invading Germans in they landed in the UK in 1940. Cut off from the UK and anxious to know the effects of mustard gas, Australia actually used it against some of our own troops (in Queensland).
Germans carried gas masks almost for the whole war, but the Allies rarely if ever carried them once they landed in Europe. The idea of gas masks and gas capes in the tropic was impossible, so no-one used gas in the Pacific. The Allies also landed on D-Day wearing photographic strips in order to check if Hitler had, or was using, some kind of "dirty bomb" radiation weapon against Allied troops.
Trenches have been a common form of defence for centuries. The Maoris used them well against the invading British in New Zealand.
Trenches were part of WW1 conflicts in Palestine, Gallipoli, the Carpathians, Italy, Russia and the Western Front (mostly France). When the von Schlieffen plan began to run out of steam, there was a race to the coast by Allied and German forces to (a) secure that flank and (b) secure the shortest cross-channel reinforcement routes for the UK forces.
Trench warfare began in 1914 and continued throughout the war. At the time, engines and metal technology was very primitive and tanks did not exist. Infantry was expected to break a hole in enemy lines through which cavalry would pour through and win a major victory, but the reality was that by the time any cavalry was ordered frward, the gap had been closed (one reason why was that artillery would pound an attack site for weeks, totally pulverising the soil which, if it rained, became a quagmire so bad that it often sucked down gun teams -- guns, limbers, horses and tracers. The lot.
Attacking infantry that succeeded soon lost again because no-one could get enough ammunition to the new front line.
Try researching aerial photos of trenches. There are the front line trenches, with communications trenches going back to secondary (support) trenches. This is where support weapons such as mortars would be. There might be more support trenches.
Trenches keep you safer from attack, but not guaranteed safe. You would cower there all day and night, often without sleep. Lice crawling over all your skin and underwear. So thirsty at times that you would dip your mug into the muddly pool near the trench wall, where the rain had drained through the bodies of dead comrades who'd been buried in the wall a week before. Going on a ammo party, to bring up more ammunition, sometimes with mud up to your hips.
The probability that the next major war in Europe would be large, general and statis should have been obvious to anyone who saw trenches and barbed wire first used in the US Civil War -- but Europeans were certain that would never apply to THEM!!