You learn more by staying and growing in a company rather than by changing jobs every couple of years.
You should try to get all you can from a company that you work for and only quit if you see no further opportunity to grow. You should work harder to create opportunities for yourself inside the company that you are already in.
Always try to get promoted and get to a leadership position in the company that you are already in rather than changing the job for promotion and more salary. It is always more rewarding to stand out among people you know.
Pushing yourself harder for growth in the company that you are currently in makes you more resilient, persistent, perseverant, resolute and determined.
Those are some of the qualities that will come handy when you want to start your own business one day.
I never applied for a job outside of my network. I never quit a job for growth. I created growth opportunities for myself everywhere that I worked for.
So, quit only if all doors are closed for you!