There are also social dynamics and logical fallacies at play.
For example, we brought on a front end developer who was about 1 year out of college and hadn't done much. After 3 years, he had devoured basically everything on the front end, but he hadn't gotten much of a raise, but was leading a team in addition to his own work. An internal position opened up that would have been a promotion for him, and when I talked to the person hiring, I got a response of "What are you talking about? He's fresh out of college". Few in the company could see past their mental model of him even though he'd grown past it by far.
He wasn't able to break away from those pre-conceived, and built up opinions. However, he left, got a new position for a quite a bit of a raise, and he's no longer known as 'that college kid'.
In that way, it's like family dynamics. Being a 'kid sister' even though everyone is in their 40s, has 2 or more kids of their own, and the age gap is only 2 years. Replace your own unbreakable family dynamics here.
It's the only way I've ever received a real raise in the past ~12 years. I even quit to start a company and came back to the same company 18 months later at $30k higher than when I left (I was originally underpaid, but still).
Yeah, that's been the received wisdom for a while now. Certainly true in my experience. Loyalty just doesn't work out for the employee. Firms know they do this and most of them don't care. The only exception I know for sure is Netflix.