Why didn't global trade prevent World War I?
It did, with careful diplomacy, for 40 years. Then it fell apart.
If we look at the pace of war in Europe, major wars between major powers, you see constant warfare up until the Franco-Prussian War of 1870. And then it, for the most part, stops. There's a period of 40 years without a major European war, an entire generation. Pretty successful. The desire to end to ruinous wars brought about successful diplomatic achievements such as the Congress of Berlin to "stabilize" the Balkans (meaning to carving them up to the satisfaction of the major powers), and the League of the Three Emperors; an on-again/off-again alliance between Germany, Russia, and Austria-Hungary to secure Germany's eastern flank and try to control conflicts of Russian and Austro-Hungarian ambitions in the Balkans.
But it wouldn't last.
The start of WWI is almost a comedy of errors goaded on by leaders whose ambitions far outstripped their competence. Like the mutually assured destruction of the Cold War, Europe was a bomb deliberately and carefully set up to go off should anyone go to war. With better leaders, this urged caution and diplomacy in international affairs. But those better leaders were gone, replaced with men whose ambitions outstripped their competence as @T.E.D. discusses in their answer. Once the fuse was lit, without everyone trying to quench it, a general European war was going to happen.
While the bankers and merchants did not want war, they were not consulted. In the opening phases, the democracies of France and UK were only indirectly involved. This was to be a war started by the hereditary dictators of Germany, Austria-Hungary, and Russia: Kaiser Wilhelm II, Czar Nicholas II, and Emperor Franz Joseph I. Unlike in the fields of commerce or democratic governments where leadership is, in part, tied to success; these men were leaders simply because of how they were born. They were not up to the task. And they could, and did, ignore or fire anyone who told them otherwise.
The Napoleonic Wars greatly expanded warfare by demonstrating the value of a large national army of armed citizens, like we have today. Unlike the small, professional cadres before, these citizen soldiers were at their jobs, not the barracks. In the event of war they needed to be recalled, get to their barracks, armed, and sent to the front. This process of mobilization could take days or weeks in the case of a nation like Russia. The rapid French defeat in the Franco-Prussian War of 1870 lead many to think that wars were won by who could mobilize the mostest the fastest. The result being nations would be quick to mobilize at the sign of trouble, which made their neighbors nervous of an attack and they mobilized. There was an almost a Cold War tension in slow motion, that as soon as one nation mobilized, everyone would.
Europe before WWI was a careful balancing act of defensive alliances between the major powers of the UK, France, Germany, Austria-Hungary, and Russia. Prior to Kaiser Wilhelm II, Germany sought to keep France and Russia from aligning to avoid being surrounded. After the Kaiser fired its primary architect, Otto von Bismark, this careful system of alliances unraveled. France and Russia aligned, and Germany aligned with its neighbor Austria-Hungary. Germany was now surrounded.
Add to this a series of treaties by the major powers guaranteeing the neutrality of various minor countries. Russia was the protector of Serbia. The UK protected Belgium.
The dominoes were all set up. After Archduke Franz Ferdinand was assassinated by Serbians, these dominoes teetered. War was not inevitable, and careful negotiation had saved the day before, but Austria-Hungary had ambitions in the Balkans. They gave the dominoes a knock by demanding humiliating terms of Serbia that Serbia could not possibly accept. Germany goaded Austria-Hungary on, eager to deal with an unprepared Russia, and promised their full support.
In his (Kaiser Wilhelm’s) opinion, though, there was no need to wait patiently before taking action. The Kaiser said that Russia’s stance would always be a hostile one, but he had been prepared for this for many years, and even if war broke out between Austria-Hungary and Russia, we could rest assured that Germany would take our side, in line with its customary loyalty. According to the Kaiser, as things stood now, Russia was not at all ready for war. It would certainly have to think hard before making a call to arms. Nevertheless, it would attempt to turn the other powers of the Triple Entente against us and to fan the flames in the Balkans. The Kaiser said he understood full well that it would be difficult for His Imperial and Royal Apostolic Majesty to march into Serbia, given his well-known love of peace; however, if we really deemed a military operation against Serbia necessary, he (Kaiser Wilhelm) would find it regrettable if we did not seize the present moment, which was so favorable for us.
Austro-Hungarian Ambassador László Szőgyény's report from Germany.
Russia and France, not prepared for war, did not make a strong stand for Serbia. Their opportunity to prevent war with a firm stance was squandered. Serbia refused the deal anyway. Germany, sensing weakness in Serbia's protectors, urged Austria-Hungary to attack immediately and swiftly. Invade and crush Serbia before Russia can mobilize, deliver them a fait accompli. So on July 28th, 1914 Austria-Hungary declared war on Serbia, sent some ships up river to bombard Belgrade, and then informed the aghast Germans they would not be ready to invade for two more weeks. And Russia was already mobilizing.
Austria-Hungary, not wishing to fight Russia alone, urged Germany to mobilize and declare war on Russia in response to Russian mobilization. Despite Czar Nicholas of Russia and Kaiser Wilhelm of Germany being cousins (as was King George V of Britain), and sending letters back and forth each urging the other not to mobilize, neither could stand down. Cousin Nicky could not abandon the Serbs. Cousin Willy could not abandon Austria-Hungary. War was on.
Germany, knowing if they attacked Russia that France would attack Germany, decided a knockout blow against France was necessary. The Schlieffen Plan was their answer to a two-front war. Knock out France in weeks before Russia can fully mobilize. To do so and outflank the French, they needed to go through Belgium whose neutrality was guaranteed by the British. Germany gambled that the British wouldn't seriously intervene, and they gambled wrong.
Despite the looming threat of a ruinous general European war, each leader acted according to what seemed to make sense in their own immediate situation. The ambitions of the Central Powers (Germany and Austria-Hungary) and the reluctance and apparent weakness of the Entente (France, Russian, UK) allowed the Central Powers to think a general war was not actually going to happen; that it would remain another quick, local Balkan war.