This was recently ruled illegal in the public sector (Janus v. AFSCME), because of first amendment concerns (the state is forcing you to pay money for union lobbying).
This hasn't resulted in a drop in membership, in no small part due to many unions adopting freakishly Byzantine opt-out measures, e.g. the ones where there's a certain window of 10 days a year that you can leave (computed relative to when you signed your union card, never advertised by the union — and if the employer even mentions these rights the union might attempt legal action under California law which forbids their employer from doing anything to "deter or discourage public employees from becoming or remaining members").
As French taxpayer I am forced to (indirectly) pay for all French political parties, including extreme right. This money gives political parties some freedom to act, to nourish the political debate... seen as a way to straighten the political debate and the democracy ; good for the general interest.
Still the number of members of a given political movement and the share of people voting for it is giving it the real power. And as someone only forced to give (indirectly) some money to a given movement is then entirely different than being force to join such a movement. And that is the same here for union.
Please note that as a worker, you are forced to "pay" for the stockholder. If you are not happy with it you can pick another oragnisation. Same goes for union, you are always free to join a union free company...