Unions don’t prevent getting rid of dead wood, people get fired from union jobs regularly. The point is they need an actual pretext to fire someone, and layoffs are more difficult.
It’s mostly protection vs the Amazon style fire people regularly so we can avoid paying unemployment insurance when we do seasonal layoffs etc.