Earlier quoted context omitted.
A friend of mine runs a web dev shop and I have seen him train at least six people from zero-to-pro (very smart, fast learners with a math background) and what you described is exactly what happens. Once they become medium/advanced-level proficient they often quit and move on to other, bigger companies. If there was some formal, or informal understanding that candidates "trained on the job" would stay for a few years…
The other replies touch on this, but I'm gonna get straight to the point: Does your friend give them actual, meaningful raises as they grow? Is he actually paying competitively to begin with? Because I think if you have this pattern that consistently, it's really likely that either you're underpaying to begin with or your raises suck or are not even present. I love working at small companies. It's by far my preferenc…
I think what's going on is that after a year at any job you start to see the problems with the code base, and it starts to get repetitive. It will be like that both in big-co and small-co, but in a different way. In small-co you can have a much more freedom, but you reach a plateau of the new things you can learn. In big-co there are bigger problems and more challenges, but you're part of a soulless machine that just wants you to do your job and not ask questions.
Not having experience the soul-crushing big-co life, the brough-up-to-speed junior hires don't appreciate the deal they have, and want to explore their options. It's a rational decision, and come to think of it I'd probably do the same. The code is always greener on the other side... Who wants to be like "no I'll stay here and do 3 years of the same things that I'm really good at now and delivering value for my employer."
From the employers's perspective though was it worth it? Time/energy invested to train them vs. maybe 6mo or 1 year of useful coding contributions.