> Although it seems like a real contract would fix most of the issues without unions.
It’s hard to disentangle these, unions are effectively the only way for non-executive[0] employees (in the US) to get an employment contract that isn’t one-sided in favor of the employer. The primary function of a union is to obtain a contract.
[0] I highly recommend reading the “Executive Severance Plan” section of any publicly traded tech company’s SEC filings, they are fascinating.