I'm curious, what about this situation but no gaps?
None of these are signals that I rely on as binary go/no-go gates; the main point was “just because you got other employers to pay you for a short while, that’s not standalone evidence that you can deliver business value through working software”.
I don’t believe in jobs-for-life, “putting in your time”, “paying your dues”, “never quit before 2 years”, or other nonsense advice, but if you’ve never had a long stint at a place, at minimum you’ve never seen the pain from your decisions 24 months prior play out and the maximum negative case is far worse.
For most of the folks I've worked with, it's the case that if they take a job and they're not learning something, they're not going to stay long. And if they take a job and the choices are "stay here, even if they enjoy it" and "take a 15% compensation bump that will ripple through the rest of their career", it would be foolish not to go for the latter.
The places that understand that retaining people takes effort are less rare than they used to be, but they don't grow on trees. If you want to hire someone longer term, I hope you're putting the money, and the investment in that worker, on the table.
To be clear, I'm talking about a persistent pattern. Even those of us with fairly long-term employment (~10 year stints) in general often have one or two short stints for various reasons. E.g. dot-bomb in my case although the job wasn't a great fit anyway.
If you were at five places for 9-18 months at a time with several six month gaps interspersed? Not evidence of absence, but that’s absence of evidence to me. (Immediately, I’m assuming several of those gaps might be flameouts.)