There’s actually a push for all custom developed code for the US government be open sourced, even if produced by a contractor. Seems reasonable to me.
It isn't something to blame a vendor for several decades after you agree to a contract when you feel like you missed out.
I understand why they do it as I like money too.
There is also donating to something because you want a for profit service to exist as something to buy.
Keep in mind there is a balance where the "ask" for receiving government funding may prevent the creation of the work in the first place.
Sometimes, the right balance may be to require the work to contractually enter the public domain in return for receiving funding. Sometimes, the government could negotiate something less than in order to get a net benefit.