Wars are expensive luxuries. Until the late 17th century, nations would tax and spend to fund wars. When the money ran out, they’d make peace. They would also borrow money from private individuals (e.g. try Googling the Fuggers of Augsburg) but the catch was that they would often default on their debts and ruin the creditors, as the Hapsburg kings of Spain did on more than one occasion. This meant that borrowing was always costly, at ruinous interest rates.
Then the English invented the Bank of England and accountable government. The latter was key, it meant that governments could not default on debts without personal cost to the members of the government, and that the state’s financial obligations had to be met. The Bank of England managed the government’s debt through bonds and assorted securities. The bearers could earn interest on the debt and could sell it (the debt) on to other investors (we call them gilt edged securities now). This allowed England to finance the hundred years of regular war against France from c. 1690 to 1815 through debt. It allowed massive subsidies to allies (Prussia, Russia, Austria) as well as financing a huge navy and medium sized army. This was noted by England’s enemies, principally France, who tried to set up their own financial infrastructure in the same way. However, as these were all absolute monarchs, with no accountability, monarchs would still cheat, default on debts and generally mismanage their countries’ economies. They still ran out of money and, with one notable exception, France was on the losing side of every war against England.
The British National Debt originated during the Wars of Austrian and Spanish Succession in the late 17th/early 18th centuries. It is still with us, added to by every war since. The First and Second World Wars destroyed the system for Britain because the cost of the wars was beyond Britain’s capacity to fund by the traditional methods. They crippled Britain’s economy to the extent that, arguably, it only started to recover in the late 1980’s.
The USA was exceptionally lucky, as previous posters have pointed out. Its enemies (Germany, Japan and Italy) were economically far weaker than itself and its principal ally, the British Empire. (Not sure about the strength of the USSR’s economy, my WAG is that it was weaker than Germany but stronger than Italy or Japan.)
The USA could afford to fight the war but only though debt, which is the traditional capitalist way. IIRC, the cost of World War Two is the principal source of the US National Debt.
Wars ruin economies, particularly non-capitalist economies, which lack the financial infrastructure to fund and manage huge government debt. The apparent profitability of British and US wars was achieved by deferring the cost (UK War Bonds from World War One are still traded in the UK, they have no redemption date) and by being financially much stronger than the opposition.
Oh, and winning helps, a lot.