Kinda yes and no.
The “no” part comes from understanding what’s happening. And what’s happening is that for every year you work there, the pay for the level you are at increases across all of them.
However, you wouldn’t be getting those increases (you would still get some, just not as significant). Talking about averages, it means that the person who got hired for the same level as you at the same company 3 years later would get paid noticeably more than you currently are (unless share prices skyrocketed, but we are talking about current compensation, not future or past; if shares tanked since you started, the new employee gets an even better deal).
Assuming no promotions or anything like that in the meantime (e.g., you are at your terminal level already or you just need more time for a promotion), you are SOL. It was almost comical at times. The mid-level dev i was working with was getting paid not that significantly more than me (an entry level dev at the time), and was only doing a little bit better mostly due to his old shares (or whatever was left of it, as he was diversifying heavily and selling the stock on vest and dumping it into etfs, so he missed out on his massive chest of old shares going 5x). He had been with the company for 6-7 years at that point. Every dev hired at his level at the time i was working with him would get paid about 50% more than him in total comp.
So yeah, the other employers would pay him more if he switched, but they aren’t “rewarding” him for job-hopping, it’s more like his current employer just not paying him as much as they would for a new hire at his level, because they are betting on the fact that he would just stay due to inertia or whatever other reasons. And guess what, they were right, as he is still there and the company saved a lot of money on him and others in a similar situation.
That’s where the good old boomerang trick of leaving, working for a bit elsewhere, and then coming back comes from. You get your salary “adjusted” twice, and then you come back.
Note: this usually only applies reliably up to senior level (aka the terminal level for the vast majority). Once you go higher or into management-type positions, things stop being this simple and work out rather differently.