If the government is the US (federal), I think you are technically supposed to release your code in the public domain by default. Some people work around this but it's the default.
But anyways, the example you've given is basically that you're paid with government funds to do work to assist industry. This is fairly similar to the people that do the work for free for industry, only this time it's basically taxpayersl money subsidizing industry. I've seen this many times. There is a whole science/engineering/standards + contractor complex that is basically one big grift, though the individual people writing the code are usually just doing their best.
I'm also an idealist of sorts. The way I see it, I'm developing publicly funded code that can be used by anyone, no strings attached, to boost productivity and make the world a better place. The fact that this gives us publicity and incentivises the industry to collaborate with us is just a plus.
Perhaps it makes the world a better place, perhaps it doesn't. This part of the industry focuses a lot on identifying a "social good" that they are improving, but the actual impact can be quite different. One person's climate project is another's strategic military site selector. One person's great new standard for transportation is another's path to monopoly power and the draining of public funds that could have gone to infrastructure. This is the typical way it works. I'm sure there can be exceptions, though.
Anyways, I would recommend taking a skeptical eye to any position that sells you on its positive social impact. That is often a red flag for some kind of NGO industrial complex gig.
Calling it a self-imposed unpaid internship, when I'm literally hired full time to develop this and just happen to have the freedom to be able to give it out for free, is missing the mark.
Well you're paid so of course it wouldn't be that.
Also, we develop these libraries primarily for our own in-house use, and see the adoption of the libraries by others as a great way to uncover flaws and improve robustness. Others creating closed-source derivatives does not harm us or anyone else in any way as far as I can see.
Sometimes the industries will open bug reports for their free lunches, yes. A common story in community projects is that they realize they're doing a lot of support work for companies that aren't paying them. When they start to get burned out, they put out calls for funding so they can dedicate more time to the project. Sometimes this kind of works but usually the story goes the other way. They don't get enough money and continue to burn out. You are paid so it's a bit different, but it's not those companies paying you, eh?
You aren't harmed by closed source derivatives because that seems to be the point of your work. Providing government subsidy to private companies that enclose the derivative product and make money for their executives and shareholders off of it.