Earlier quoted context omitted.
It isn't one or the other, there is value in both staying for a longer period of time and moving more frequently. When moving more frequently, you can be exposed to a wider variety of problems and have a more complete picture of the profession and the various pitfalls. Plus, you may have the opportunity to learn from and correct the mistakes of others. It can accelerate your growth and pay substantially if you are do…
I think it's good to have a bit of variety - one or two roles where you stayed 3, 4, 5 years, then a bunch of companies only 1-2 years each. You'd have some depth of experience as well as breadth.
Once you hit the job that really really suits you (say you like algorithms and this job occasionally needs some), you are less likely to move no matter how experience you are already. While you are on positions that are meh to you, you are more likely to want change soon.
Of course you don't want company stucked with only people who are new there nor only with people who never worked elsewhere. But then again, company should have idea about which position requires more stability or how many of each type is there already and factor that in into decision process.