I don't think this is only for leadership roles. If you don't stick around long enough to see how your work has evolved, your APIs have been used, how easy is it to adapt your work to new requirements, how you handed over ownership to someone else/another team etc etc, I think you left very valuable learning opportunities on the table.
Job hopping attitude is very visible in someone's work as well. You see them focusing on short term gains only with most of their technical decisions and leave the mess for someone else to cleanup while they move on to the next thing. Zero skin in the game.