I'd say the union was one of the main reasons why we didn't have mass layoffs when the company was in a hard spot. Instead more acceptable options like part-time and voluntary resignation with exit packages were negotiated and still met similar cost saving goals.
In small shops you probably won't have a union but they don't tend to hire&fire like the big multinationals.
And definitely Sweden. Many (most?) of my software engineer colleagues are members of either the engineering-specific "Sveriges Ingenjörer" or generic white-collar "Unionen" union.
I am in Germany and I never heard of any union for Devs, not even large firms having any specific ones for Devs. My colleagues frequently discuss about unionizing but there are huge pay disparity hence most often it is hard to get everyone on board sadly.
Most unions are intended for craftsmen, minijobs, public transports and such. There are some small employers covered by famous IG Metall tariff but that is not the norm. I know that likes of Airbus has some kind of union that covers most of the departments and hence pays insane salary but that is something I heard from friends of people who work there, so I can’t assure accuracy.
There might be unions but that is not the norm except some dinosaurs.
Even 40% makes a huge difference, though.
And the union deals on insurances, mortgage etc. saves me much more money each year than the union fee.