In what world is it justified to treat your loyal employees this way? Why do companies do this?
It's not. Because they can get away with it.
Since people lack independence and the (mental) freedom to pack up, leave, and go where they're treated best, there is barely any pressure to give raises. That's why it's recommended to move to a new job every few years. But that's still super slow.
When I started freelancing I raised my own rates from $15/hr to $150/hr (average since I switched to value-based flat rates) over the span of 18 months. Nobody is gonna give you a 10x raise over 18 months or pay you anywhere near what you're worth unless you have serious leverage and it's very difficult to replace you. Now I make what I want 9 years later.
People don't know how to do that on their own, people don't know how to leverage their worth, they don't know how to increase their perceived value, and they don't know how to sell that perception for higher pay. In a company or outside.
Because of course the employer who is incentivized to depress wages would never teach you that.
So all they learn is how to execute. All they do is execute. And then are satisfied with some 1% increase that doesn't even keep up with inflation and are happy that "I've got a raise!"
Meanwhile new hires have higher expectations because of said inflation or market conditions have changed or maybe they're more entitled. So they have to be paid more.
The employer will not give the older folk raises to exceed the new hires because that's a bad precedent to set in their eyes. Gives people funny ideas. So they'd rather fire someone who feels undervalued than make better use of their skills and experience by compensating them higher. Or they promote them to manager despite not having management skills to shut them up and they ruin everything.
It's a tale as old as time.
I don't understand it either. Seems like awful management. But when the managers are the people who felt robbed 10 years ago it's to be expected that they perpetuate the cycle of devaluing.
Learn what you're worth in the marketplace.