Why would anyone have loyalty to a company that has no loyalty in return. This is especially true in the US with employment at will. It's less true in some countries but is usually legally enforced as opposed to cultural.
My wife's career has been defined largely by strategic hops. Her reputation has been built up by doing good work -- her title and salary are almost entirely due to moving around when it was advantageous.
A lot of companies are reluctant to promote internally due to office politics. In my wife's industry, it's nearly impossible to go from XXX to YYY at the same company. So, she joined a much smaller company that could only offer title advancement. Six months later she was back at a major player, with title YYY and the salary to match.
(The CEO of that company called her a job hopper.)
She did the same thing hopping out of the industry to take over a company as ZZZ. Now's she back in as an AAA, one position away from running the company (a top company in her industry).
Her industry needs more YYY and AAA, but won't promote to create them. Catch-22 they only want to hire people who already have those titles. So, your choice is either grind with little or no real advancement or use companies and their current situation to your advantage.
This is necessary and isn't just about your personal gain. My wife's career has helped a lot of her younger colleagues navigate their own.
Employees owe companies nothing. Act accordingly.