There's a multitude of ways of handling it. Both of what you mentioned aren't outside the scope of reality in theory. There's a lot of ways of paying for it, like auditing the Pentagon, considering how it loses track of trillions each year. or changing tax law to have less loopholes and capture some of the 32 trillion being stored in offshore tax havens. However, there's not much point in talking about the specifics in actually implementing it because the political will isn't there. Politically, we're not even onboard with getting lead out of our water, let alone ensuring minimum standards for everyone. Like you said, good luck paying for it, because that's not what government wants. We're in a state of regulatory capture, so it wants whatever the most influential donors wants.
To be fair that "lost" pentagon money is money that was spent. It cant really be used to fund other projects unless you cut what it was spent on and even then its not recouped. The next FY the item doesnt get funded and in theory if tax receipts are the same or higher you can reallocate that money.
The only way to do it during a FY is to defund something and use the money elsewhere. Of course that comes with its own set of issues. When Congress gives money to say the DoD to use your example it approves a budget that has specific amounts in it as different "colors" of money. For example some money is procurement and some is R&D while other is pure labor. Labor money cant be spent to buy a server becuase its not what DoD said to Conress it would do with that money. In the same vein procurement money cant be used to pay for someone to do something...
There are ways to convert money to other types but it involves a lot of paperwork and often its very expensive in terms of manpower and time to make that change happen. And thats just inside one department...imagine what the paperwork would be like to move it from DoD to say State...it would take an act of Congress most likely.