Imagine firefighters having to ask some insurance company to cover the water they need to put your house out.
It literally used to be like that. Firefighters would refuse to put out the fire if you didn’t have evidence that your fire insurance covered them.
Unions typically have an agreement where employees don’t have to join the union but they still have to pay a fee equivalent to union dues, and the employer can’t pay non-members more than union members, or other similar restrictions.
The idea is to remove the ability for the employer to offer an advantage to non-members.
TLDR it’s an essential part of making a functional union.