I get what you're saying about the salaries -- our company just recently started a program to normalize salaries with the market and it was certainly sorely needed as we had become notably out of sync. But from the perspective of the business, we don't start getting a strong positive ROI out of a new hire until about a year in. To turn over staff after less than two years is a real cost to us and potential employees that are prone to that are often not the best choices when that risk is factored in.
I also reject your false dichotomy. There are not just two reasons to stay at a company for 10 years. You could, as just one example, strongly care about the mission of the organization and/or the work that you are doing. People do work at nonprofits despite their generally lower salaries.
I'm sure you have pursued all avenues with the company you are currently at, but on the off chance you haven't tried it, I suggest talking frankly with your manager about your market value (backed up with hard numbers from reputable sources) and pointing out that their cost to replace you _and train your replacement_ would greatly exceed the cost of bringing you up to a competitive salary. If the manager has latitude and a brain, this might work for you.