I think it's important to understand that there's a significant amount of selection bias possible here. In general, folks who switch jobs every two years are the folks who are not getting offered big raises by their current companies. The ones who are getting offered big raises may still choose to leave due to other reasons, but they often will choose to stay instead. And they won't be making a big fuss about it onli…
Imagine you have a very talented engineer that joins Company A out of college. They pick up new skills quickly and do an excellent job with everything they get thrown their way. The reality is that the company isn't likely to give them a 50% bonus overnight just because they deserve it.
Whereas you can get another person that comes in from another company (and many more before that) and due to the nature of jumping around has the title and the base salary going for them. They very well aren't as good as this other person, but just because they have what they have, they keep getting it.
To be really successful as an engineer, you need to know your stuff, and also know what you are worth. I've seen so many talented engineers stick with companies that are paying them way under market value just because they don't feel like applying anywhere else and they don't know how much more they could be making elsewhere.