You're right that military spending isn't mandatory, that's why the gov't goes to such lengths inventing imaginary evils around the world that we then go blow up. That $40 billion quickly rushed through Congress last week "for Ukraine"? SPOILER: that money is staying in DC. All the weaponry we've shipped the past few months? All obsolete mothballed stuff that now must be replaced by the next generation tech! Lockheed, Raytheon, Grumman, etc.
Military eqpt is about the only thing still produced in the US and even that would've already been offshored if there weren't laws prohibiting it. A significant percentage of each state's highest-earning population works in the defense industry. Gotta keep that propped up too.
I will point you to President Eisenhower's farewell address where he warned against just this.
https://ancillary-proxy.atarimworker.io?url=https%3A%2F%2Favalon.law.yale.edu%2F20...
https://ancillary-proxy.atarimworker.io?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2F...
Until the latest of our world conflicts, the United States had no armaments industry. American makers of plowshares could, with time and as required, make swords as well. But we can no longer risk emergency improvisation of national defense. We have been compelled to create a permanent armaments industry of vast proportions. Added to this, three and a half million men and women are directly engaged in the defense establishment. We annually spend on military security alone more than the net income of all United States corporations.
Now this conjunction of an immense military establishment and a large arms industry is new in the American experience. The total influence—economic, political, even spiritual—is felt in every city, every Statehouse, every office of the Federal government. We recognize the imperative need for this development. Yet, we must not fail to comprehend its grave implications. Our toil, resources, and livelihood are all involved. So is the very structure of our society.
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. We must never let the weight of this combination endanger our liberties or democratic processes. We should take nothing for granted. Only an alert and knowledgeable citizenry can compel the proper meshing of the huge industrial and military machinery of defense with our peaceful methods and goals, so that security and liberty may prosper together.