(The spent shells of an Artillery Battery. This is from approximately a days worth of firing)
There is no easy answer to that question. Every nation had different reasons for fighting the war. The Germans became involved in the war because of their alliance with Austria-Hungary. The British became involved due to the German invasion of Belgium. These two nations had no direct reason to go to war with one another, but they ended up being two of the core belligerents.
For the Germans, the war was seen as a way to establish itself as the dominant power in Europe. The German Emperor, Kaiser Wilhelm II, very passionately argued for war. As the war progressed, it became less about dominance and more about simply salvaging the war, and making it all seem worthwhile. Top German generals took over control of Germany, and fought the remainder of the war to save face.
(The Kaiser was essentially powerless after 1916.)
The United Kingdom started the war to fight against German aggression. The invasion of Belgium gave the U.K. a Casus belli, and they went to war expecting a short, sharp war. What they got instead was 4 years of bloody struggle and 800,000 dead. It was rationalized to the public as a war to defend liberty and freedom.
France entered the war to honor a treaty it had signed with Russia. This treaty guaranteed that if Germany declared war on Russia, France would attack Germany. When the German army proved almost unbeatable in the early days of the war, France lost a massive proportion of its industrial capacity, and massive swaths of territory. Knowing that if they simply surrendered or tried to broker peace they would suffer a national disgrace, they continued to fight on and on.
(the typical uniform of a French soldier in World War 1)
So while there was no singular reason as to why the war was fought for 4 years, the definite trend seems to be national pride, and saving face. When these nations started a horrific conflict, they needed to be able to rationalize it to their people, who often times could only see the terrible loses they were suffering, and not the grand strategic aims of the generals.