Because after 2-3 years you can move for (on the very low end) a $10-20 grand pay increase without much pain at all. A raise you'd be unlikely to get at your original job. I am unsure of how a union could address that problem. It's a sellers market for software developers.
What I'm hearing you say is "Employers are not providing raises commensurate with employee experience and value, leading to churn and a lack of mutual investment".