It's probably true on average job hopping pays off when you're young, it also has some real upside risks as more senior positions generally require you to think longer term, and that's very hard if you don't see how your actions and decisions play out.
As a hiring manager, three 2-year stints would be perfectly reasonable for an L5 candidate, but five 2-year stints I would be very concerned about hiring an L6 expected to drive long-term architectural directions.
Ultimately I think the "learning or earning" advice is better. When you are young you should chase your interests and prioritize personal growth and finding out what you are good at. The primary heuristic should be whether you are learning quickly, and are you surrounded by people and structure that help you with that. Later on in your career when you have more personal responsibilities you should prioritize earning, and hopefully you have built a foundation of strong and deep expertise that qualifies you for more senior positions. Of course if you can get both, that's great, but you also need to be careful because a lot of things you learn at the best paying companies have limited applicability outside that bubble.
As a hiring manager, three 2-year stints would be perfectly reasonable for an L5 candidate, but five 2-year stints I would be very concerned about hiring an L6 expected to drive long-term architectural directions.
Ultimately I think the "learning or earning" advice is better. When you are young you should chase your interests and prioritize personal growth and finding out what you are good at. The primary heuristic should be whether you are learning quickly, and are you surrounded by people and structure that help you with that. Later on in your career when you have more personal responsibilities you should prioritize earning, and hopefully you have built a foundation of strong and deep expertise that qualifies you for more senior positions. Of course if you can get both, that's great, but you also need to be careful because a lot of things you learn at the best paying companies have limited applicability outside that bubble.