No, it's not. It's the law that unions must represent anyone whom they claim as part of their bargaining unit.
However, unions have great freedom to define bargaining units how they like. They already take advantage of that ability, in order to invalidate decertification elections (by retroactively choosing a differently-sized unit from the one that was eligible for the election).
The law you are citing exists because unions are authorized to collect dues from all members of a bargaining unit, including those who don't belong to the union. The law ensures that unions don't extract money from non-members while also refusing them representation. Otherwise, they would literally be allowed to charge as much as they want, and people who don't join would simply be paying for the benefits of the people who do.
There is no free-rider problem, because those members are only included in the bargaining unit because unions want to use them to pad their numbers. If they weren't able to collect dues from them, they would simply redefine their units and walk away with the same net revenue from their members.