It really depends - if you're chasing more money or a bigger title, hopping jobs is often the only real way to achieve that.
If you're content with your salary and your title/responsibilities, there's nothing wrong with sticking around either if you like where you work. But a toxic workplace will lead to burnout faster than anything else.
The market is also absolute trash right now, so there's something to be said in holding onto the stability of what you've got if you're happy with it.