Earlier quoted context omitted.
Why should laws say employers can't voluntarily sign a union security agreement? Because (at least pre-Hobby-Lobby) laws have historically prioritized the rights of individuals over the rights of corporations. An employer which compels their employees to join a union is signing away the rights of those employees, while an employee who signs a non-compete is only signing away their own rights.
The compulsion in both cases is exactly the same - pay union dues/sign non-compete, or find a new job.
If the employer has a mandatory unionization agreement, you can't negotiate with them to change the terms of that.