Tragedy of the commons. What stops a company taking on the strong junior engineers you just invested time and resources into?

Not a lot, so you should make sure you give them generous raises and other incentives to stay.