Unions don't add economic value, hence why employers don't like them. The way they secure higher pay is by going on strike, not by offering more production or value.
Unions provide training, good healthcare, and safety, which very much add economic value. Employers typically have the full force of market forces to pay as little as possible. Collectivisation is the workers only means to advocate for themselves.
How would unionizing prevent you from being replaced by a machine? Striking isn't a threat when you not being there is what the company is going for anyway.
Automation is not instant, and if the clock is between “implement AI correctly to automate the work” and “run out of money because you have no workers” a strike is still effective.