It is true that the Great Depression by many measures still had a tight hold on many western economies at the start of 1939 when the “war economy” distortion of WW2 took hold. It is also true that, after a period of recession from mid-1945 to mid-1947, the US economy specifically began to grow prodigiously. The problem in assessing “why” this was turns on two difficult questions: (i) why did the Depression occur and last so long and (ii) which changes in the economies of the world occurred due to war spending versus the wartime and post-war diplomatic and political efforts to reform and redraw the global economy? I’ll address these in turn.
First, it is generally understood that the Great Depression began with a financial crisis in 1929 that started on Wall Street, and quickly spread around the globe. But the strange thing about this financial crisis-induced recession is the fact it lasted so long compared to comparable ones in the past. (Before the 1929 Great Depression, Americans used the term “Great Depression” to refer to the four-year recession after the “Panic of 1873”, which was the longest, severest global crisis to that time.)
WW1 had driven the economies of Europe off of the gold standard, and left the UK, France, and Germany hugely in debt (or indemnity in the latter case). This had transformed the financial industry, and dramatically changed the role of the US in the global economy as the key creditor. In addition, finance began to grow much faster and more creative while the regulatory apparatus did not change to meet the new risks this created. This turned the finance sectors of the US and UK in particular into ticking time bombs.
At the same time, global finance faced the large challenge created by Germany’s tottering economic and political position under the burden of Versailles Treaty reparations. Lenders in the US, being the only economy not suffering under huge WW1 debt, moved to provide credit to the Germans and redraw their payment schedule. At the same time, the US refused to write off the huge loans it provided to Britain and France during WW1. The strains of bickering over these issues among the allies, combined with diplomatic spats between France and Britain, lead to a severe reduction in trust and cooperation between the allies through the 1920’s.
When the Great Depression hit with the 1929 Wall Street Crash, international cooperation held for a period of time. President Hoover gave a voluntary pause on war debt repayment to France and Britain. An ultimately failed effort was made to save Germany from economic and political collapse under the Versailles scheme. But just as the “first wave” of the Great Depression began to reach its “natural” (compared to prior experience) ending in 1931-32 another wave of crisis broke out. Starting with the UK the Western Allies began “competitive devaluations”, reducing the values of their currencies to increase exports. This set off a whirlwind of measures that left international trade a shadow of its former self. Hitler won the Chancellorship of Germany in 1933 and ended Versailles payments. In 1934, Britain and France defaulted on their WW1 debt. In retaliation the US passed the Johnson Act closing UK and French access to private US credit markets, and the Smoot-Hawley Tariff Bill raising tariffs on everything in sight. The Europeans did the same.
So rather than recovering naturally from the 1929 shock, the West entered a new round of contraction of commerce and credit. In the US, FDR and his New Deal engaged in social and stimulus spending on an unprecedented level (though not large compared to spending that would come during the war). They hugely expanded federal regulatory power. And they intervened in several markets to prop up prices and wages to support workers. But, while this was hugely popular among farmers and the working class, there was not much understanding of how to do it effectively. Results were limited or even negative.
Which brings us to the Recession of 1937, a “second Depression” that struck just as things were improving. This is still one of the most contentious intervals in American economic history, so there is no consensus “right” answer as to why it occurred. But the simultaneous reduction of deficit spending in 1937, combined with changes in banking regulation in 1936 that caused a new financial crisis in the form of mass failures of small banks across the country, resulted in another round of contraction. This tumble resulted in a spike in unemployment that didn’t end until 1939.
But it is important to note that, by 1940 the US economy was improving. Skeptics point to the fact that in 1940 the US was starting to get large foreign contracts from the UK and France to equip there armies. And in that year the US began its expansion of its armed forces to prepare for war. But the sums involved in these efforts were still small compared to the “slack capacity” in the US economy. (Note that, because of persistent anger in the war loan default of 1934, British and French weapons purchases could only be payed for in cash. They could not buy with borrowed money, limiting the scale substantially.)
By early 1941, even prior to Pearl Harbor, the scale of war spending had changed. The US was moving all out to arm, with FDR’s promise to build “50,000 planes a year”. The Lend-Lease Act had saved Britain from its money problem (France was now out of the war). Knowing Congress would still not lend money to Britain, all Britain’s war materiel was made effectively free, to be paid for by American taxpayers and war bonds. As the war unfolded, the US put 10 million men in uniform and mobilized women into the workforce on a massive scale. The transformation of the economy was astounding.
But at the end of 1945, the bonanza ended. With victory, war production ended. Women left the workforce in droves (no one at the time knew this would only be temporary). The US was doted with factories and shipyards that were now useless and were scrapped or left to rot. The United States and United Kingdom both entered steep recession as their economies had to totally reorganize. The US and Britain found that all the economic capacity they had developed had little value in peace. They had millions of citizens with decades of backpay (or stacks of war bonds) to spend, but they needed to solve the problem of allocating those people into productive peacetime activities.
This brings us to the Second part of the question. Even during the war, forward-thinking officials in the US and UK were working to build a framework for diplomatic, political, and economic cooperation after the war. They wanted to be certain that the selfish breakdown of 1931-1934, that had turned the democracies against each other, would not happen again.
There were three main pillars of this program. First, in order to prevent competitive devaluations, they adopted the 1945 Breton Woods system of fixed exchange rates. And rather than implement this only bilaterally, they opened the system to all the allied nations that had fought beside them (which they called the “United Nations” during the war). The USSR declined to participate, but most of Western Europe and South America signed on.
Second, they implemented a program of tariff reduction and trade-promotion to encourage commerce. For political reasons this wasn’t formally enshrined until the 1948 GATT, but measures started even during the war, allowing all participants to enjoy reciprocal “most favored nation” tariff status on most goods. This disallowed punitive bilateral steps, and established a framework for ever-diminishing trade barriers to allow the huge scale of international trade that we know today.
And third through establishment of the World Bank (and Reconstruction Fund) and later the Marshall Plan, the Allies provided credit (or grants) to ensure prostrate foreign economies would recover more quickly. This allowed the economies of Europe to recover much faster than would otherwise be expected. And it provided a framework for a global perspective on economic policy.
Taken together, this meant that the US emerged from the war into a global economic environment totally different than the one that had existed prior. And the results showed. The US started to recover in 1947, but didn’t start to really grow until 1949. This is important to contrast with Britain, which had been in a better position than the US prior to the war, but swiftly began to do far worse after the war. (I only reference this because it evidences the fact that the transformation of wartime economic activity into peacetime prosperity is not obvious or inevitable.)
Your question is complex and is still politically fraught to this day. But the Great Depression is unusual among downturns for its length. It isn’t “natural” in a liberal economy for 15% of workers to remain unemployed for years on end if they are capable of being productive. The lesson I want to underline is the fact that the Depression was extended by a sequence of policy errors and miscalculations domestically and internationally. While the huge spending of wartime managed to temporarily utilize America’s slack capacity, it would not have been a lasting gain if everyone had gone back to making the same mistakes. The postwar international economic reforms were ultimately vital to the US’s lasting economic growth and prosperity. And the effectiveness and importance of international cooperation in alleviating recessions was shown by the success of cooperative efforts in preventing the 2008 Financial Crisis from turning into a decade-long economic depression.