This is what I've personally experienced from both ends. I was at one company for a very long time and as a result I was dependent on the variable annual salary review (which was at least consistent) but in the last decade or so I feel that compensation for needed jobs outpaced that growth. I've also noticed that viewing the profiles of various software engineers that a lot of people move around a lot. They might stay there one or two years but no more than three or four. I wish I had learned this early on in my career. Also I think as a developer you learn more and grow by experiencing different domains and problems. It's bad to get complacent.
> It's also surprising how many companies will allow great engineers with 5-10 years of domain experience to leave with just a "ah, it's normal, attrition happens" without actually trying hard to keep them, but I guess they figure that if they reward one for staying, others will want rewards as well, and so it's easier to just not do anything (which is of course helped by the widespread notion that engineers are just replaceable cogs, so if one leaves you can just get another or hire 3-4 offshore replacements for the same amount)
I sometimes wonder if long-term employees are a liability for companies. Or if they view them that way at least. Because of the nature of work maybe they need people for a few projects and if they go that's okay. They got what they needed from them (and maybe so did the employee).