It's a valid concern - that by training your employees and giving them experience, you make then so valuable that they can leave.
I fight this problem several ways:
I turn our services into a products so that I can onboard people quickly and drive down costs - for example instead of telling each employees to setup a backup on a server, I had one employee make a script that we can deploy on all new servers. By turning processed into an easy to deploy product - It also keeps boredom low.
I give raises quickly and early to match new skills, so that when they do go job hunting they don't see a tremendous pay increase.
I compartmentalize employees so that they get really really good at a smaller range of skills - this lets me charge the customer more, and lets me pay my employees more, but it also has the side effect of diminishing job prospects.