Trench warfare wasn't so much a preferable style of fighting so much as it was the only way to keep an army alive. The technological advancements of the machine gun, artillery, and "repeating rifles" made it extremely deadly to be out in the open; several yards of earth and concrete was the only way to avoid death by bullets or shrapnel.
Infantry charges across open ground on an entrenched position were only rarely successful and virtually always resulted in horrific casualties for the attackers (this was already a factor in the American Civil War, as well)- much of the weapons development during the war was seeking a way to break this stalemate, whether it was with artillery barrages, poison gas, or tanks. All of these sought to disorder the enemy lines and keep the enemy machine-gunners from raking your exposed lines with a hailstorm of bullets while they crossed the open fields and got tangled in barbed wire.