How often are unions used to enforce political/ethical stances about management’s treatment of third parties, rather than workers? I hadn’t really considered altruistic uses of collective bargaining power.
Look at professional guilds like the American Medical Association or the Bar Associations. They both major focuses on professional ethics and use their power to enforce those ethics, both by being able to bargain with corporations or the government and by holding power over their members. Getting disbarred is the end of your career as a lawyer, and so it behooves you to comply with their ethical standards even if you don't personally care about them.
It's a little harder for programmers because the ethical bar is less agreed-upon. "Doctors should help people" and "lawyers shouldn't steal their client's money" are pretty nearly 100% agreed-upon by the professionals, but there's still a lot of disagreement on what is and isn't ethical for a programmer to do.
Unfortunately exponentially rising health care costs and excessive litigation may be the two to the largest problems with society in the US at the moment. Whether those guilds help mitigate these problems or amplify them is hard to determine.
It appears to me that law and medical licensing bodies are advocates for the public against the professions. It may be incidentally beneficial to the professions in some ways (trust, etc) but the same can be said of environmental and safety regulators (accidents cost time, etc).
In what sense are they unions?
"Software engineers need to be protected from the employers" and "the public needs to be protected from software engineers" seem like very different positions, in fact I can imagine both organizations existing in a sometimes-adversarial relationship.
They are unions in the sense that they draw their funding from membership fees, set high entry standards that keep competition in check for existing members (obviously there are altruistic reasons for this too, but one impact of requiring a long, expensive degree is low competition). The union structures in medicine and law and piloting tends to favor established members over new ones.
IMO setting high standards is a quality shared by any healthy industry, because permitting shoddy work means every consumer needs to learn the details of the task in order to judge their provider.
In the context of this thread, it seems very much to be the case of "the public needs to be protected from software engineers." The N'th ancestor post very explicitly says that "we" are causing this problem.
The idea being, if professional strictures were imposed upon us, that would give us a stronger ability to push back against those who set tasks in conflict with those strictures.