There is always version lock in at some point, and NO workers like change if it's going to cause them to lose their livelihood. This has nothing to do with unions.
Why do you care more about protecting artificial constructs like companies at the expense of power given to people building the products?
For example, when the ACA passed, unions were more concerned with their constituency and their carve outs than with decoupling employment from healthcare. Same story for all the business interests.
The argument is much more nuanced than you’ve proposed.
However, the whole firing topic is really only filling up a fraction of unions' time. Unions' main tasks are overwatching safety regulations, crunch times, etc... so that the actual time spent at/for the company is better quality whise. This leads to happier, healthier programmers which should be in their employer's interest as well, see e.g. negative press and lack of battle proven personel at telltale.
A union would go nuts in that scenario. Which then supports the theory that unions would oppose technology that improved efficiency since they would care more about the protecting the production input than they care about optimizing the production output.
This article is one of many discussing the dawn of truck automation in very much detail: https://teamster.org/news/2018/01/teamsters-union-perspectiv...
As you can see unions are in fact discussing this very broadly without jumping to easy conclusions.
Automation by ML is a complex topic on all levels. We are just at the beginning of what will be very interesting times regarding policing automation, ML, and AI.