There are 3 ways the US can economically benefit from militarization. Only one really requires "going to war" and only under particular circumstances at that:
The US benefits from rather massive weapon exports. No actual war is needed.
Military spending benefits a large slice of US society
As other answers have stated, there is very much the notion of the military industrial complex.
A vital element in keeping the peace is our military establishment. Our arms must be might, ready for instant action, so that no potential aggressor may be tempted to risk his own destruction. . . . American makers of plowshares could, with time and as required, make swords as well. But now we can no longer risk emergency improvisation of national defense; we have been compelled to create a permanent armaments industry of vast proportions. . . . This conjunction of an immense military establishment and a large arms industry is new in the American experience. . . .Yet we must not fail to comprehend its grave implications. . . . In the councils of government, we must guard against the acquisition of unwarranted influence, whether sought or unsought, by the military-industrial complex. The potential for the disastrous rise of misplaced power exists and will persist.
This doesn't require going to war either. To be clear, the benefit to US society as a whole, is not a given at all. Rather the opposite. Foregoing the DoD $857.9B for FY 2023, might be used for social/environmental goals, it may allow cutting taxes, it may allow paying down the debts. As a whole, US society would benefit from reapportionment, in a safer world. But for the men and women employed in defense industries and in the armed forces, that spending is a boon and that creates a powerful constituency to keep military spending high. That's why the F35 project deliberately has contractors in almost every state and that's why the DoD has such troubles closing bases it doesn't need anymore.
Loosening up purse strings:
The third way, which does require going to war, happened in 1940-41. Remember that the Great Depression had been made worse by governmental budget cutting - motivated by lower tax intakes. It took a while for the idea of spending money to get out of the self-reinforcing death spiral took root.
Once the US went to war the spigot of government spending was opened wide, Keynes won the day, and for various macro-economic reasons the pent up US underperformance was reversed. As mentioned, yes, the industrial competitors to the US had also suffered grievous reverses during WW2 so that helped as well.
The notion of wars stimulating economies is not that controversial, but while an occasional war may do so by concentrating spending which ramps up industrial capacity and spreads costs over time, it is hard to see frequent wars being a benefit.
Another dimension here is increased technological advances during wartime: WW1 brought us the airplane, WW2 radar and jets. (And many others). But the world in 2023 is very different from 1914 or 1939: a lot more technological innovation is driven by consumer/commercial demand rather than cutting edge military investments. Especially when Western weapon systems have 15-20 year design cycles in peacetime.
But the only one of the three requires going to war and is a benefit to US society as a whole is not a frequent type of event. Furthermore, Keynesian spending is well entrenched, some would say too well, entrenched in Western thinking anyway.
Resource acquisition/commercial interests:
Certainly some would argue that the US gains from access to resources/contracts as a result of war. Does it? The clearest example of that happening is the 2003-2004 reworking of Iraqi laws under Paul Bremer, to allow for privatization and preferential access to contracts for companies from "deserving countries". The end result was most certainly not of great benefit to the US though some well-connected US companies benefited handsomely.
From February 2022 on, one might however mention a somewhat forgotten reason: keeping a nation and its supply lines safe and independent. Yes, military spending can trigger arms races and become self-fulfilling prophecies, but it would be remiss to forget that the US is far from the only powerful country that tends to resort to military action.