Question: Why bother to attack in trench warfare?
Ignorance mostly. Ignorance which was only overcome from several years costly losses trying to attack entrenched machine guns with infantry at the beginning of WWI.
Why attack a chariot column on foot? Why confront an army wielding iron swords when all you have is bronze knives? Why would armored Calvery charge entrenched archers across a muddy stream? Why would people try to climb midivil castle walls? Why did the United States in 1941 bottle their entire Pacific fleet up at Pearl Harbor even knowing an attack by the Japanese was imminent?
The answer to all these questions is because they didn't know any better. Because history had not yet demonstrated the sheer stupidity of these actions yet. Although already proven wrong in the British Crimean War and American Civil War conventional wisdom in WWI was massed infantry would overwhelm defensive formations.
In Crimean War(Battle of Balaclava) and the US Civil War(Picket's charge) the Minie ball, which enabled the wide use of rifles over muskets with their vastly improved accuracy turned the Napoleonic tactics of platoon firing into a then unprecedented bloodbath. In WWI the machine gun turned the same tactics of volley fire into mass suicide.
Why did trenches even occur? Because frontal approach of machine gun positions caused so many casualties they couldn't mass enough troops and keep them alive long enough for a proper offensive. Then they figured out that even massed overwhelming infantry emerging from trenches close to the enemy positions also stood no chance against machine guns the stalemate which was WWI began in earnest.
Long story short. Practical military experience historically speaking is a see-saw; for a time the defense will have the advantage and offensive actions bare the primary costs for battles ( see feudalistic middle ages with their great stone castles, or see the machine gun in WWI ); and then everything changes. Some new technological innovation or tactic and the offense has the advantage. Now it's near suicide to be on the defense ( see introduction of cannons and how it changed castles or see the introduction of the Tank and the German Blitzkrieg). The flip side of this is most armies which fight wars, begin their war using the outdated and often suicidal tactics that would have worked well if they used them beginning their last war. ( see WWII, battle of France and the Maginot Line).
We are still going through this pattern today.. In 2006 the Israeli's fought Hezbollah in southern Lebanon. Israel used the tried and true Armor attack supported by air superiority, artillery and infantry. Basically the same tactics Germans used against France and the same tactics Norman Schwarzkopf used against Saddam. Only in 2006 Hezbollah had an answer. Pre fortified tunnels, sophisticated American and Russian anti tank and anti personal missiles. First defeat in Israel's short history of overwhelming militaries victories.. or at least the first time any Israeli Army has left the enemy in the field and retired.