When I used to work in defense contracting, this is precisely what we (the contractor) did. We would buy up all available stock of any difficult-to-replace parts (often specific SBCs) when the manufacturer announced end of life.
There's a market in conforming interface and ABI spec meeting hardware to emulate the boot and upgrade devices for German tanks, or some other hardware. Sd card or USB behind, giant milspec plug to the fore.
Doesn’t it rot?
Given that it's definitionally military-grade hardware, and very high value-density and therefore easy to store very securely, I doubt it.
Ben Rich talks about this being a rough spot for dealing with military contracts in the epilogue of his book, Skunk Works. I think it depends on the contract, for plane parts they did not allow for storage of parts :(
I guess they want the capacity to make planes indefinitely, if a really big war happens?