Tactics switched to trenches to counter direct fire small arms, not to counter artillery. By the end of the American Civil War, trenches and field works were becoming far more common then ever before, but this was not due to advancements in artillery-in fact field artillery saw little improvement up until this point. Small arms however became dramatically more potent due to inventions like the mini ball and the advent of widespread army issue rifled firearms.
MG-42 fires at 1,200 rpm. If machine guns were the death of open terrain warfare then why did all the German generals cry in their memoirs about human wave attacks on the eastern front? Why not trench up and own the ruskies if this is the case?
The confederates fired the largest artillery barrage of the war before Pickett's charge. Shouldn't that have devastated the Union trenches?
If direct fire weapons are so deadly to open terrain combat then why the move to tanks? They too are countered quite easily by direct fire weapons.
If trenches exist solely to counter direct fire then we would expect WWII to have been a war of tunneling machines, not mobile armor.
Pop-history wants to talk about whats sexy and new because they want to sell books. They don't want to talk about what's actually effective i.e. incremental advances in artillery size and density.
At Waterloo there was one artillery piece for every 477 men. Most were around the 6 pound range. (https://en.wikipedia.org/wiki/Order_of_battle_of_the_Waterloo_campaign)
At Gettysburg there were similar numbers at one piece per 578 men, however most guns were around the 12 pound range. (https://www.teachersfirst.com/gettysburg/weapons.cfm)
In WWI a standard british infantry division had one piece per 236 men. 18 pound guns were the most common. (http://militaryhistoryvisualized.com/british-infantry-division-19141916-visualization-organization-structure/)
In 1944 the standard German infantry division had 76 mortars and 48 guns for 12,000 men. A ratio of an artillery piece per 96 men. (https://www.ww2-weapons.com/germany-army-unit-organisation-1942-45/)