There are many thoughts and ideas on how long you should stay at one company. The traditional method was you stayed at a company as long as they kept you employed and there was a sense of loyalty and you retired with a nice pension. Now, there have been methods promoting the opposite which is to not stay longer than 3 to 5 years at one company so you can climb the corporate ladder more quickly and get raises more quickly. I think in the first method you can fall into the trap of complacency and the second method you can fall into the trap of being selfish and both lead to problems that will cut your future short. I think following generic advice on quantity of years to stay in a certain position or at a certain company can cut short a season or drag one out too long.
There is a popular scripture, Ecclesiastes 3, that says there is a time to every season and a time to every purpose. I have been at my company for 9+ years now and there was a time that I wanted to leave and grow in my career and I found a great opportunity to do so. Well I turned in my two weeks notice and had a conversation with my manager and later had a conversation with my plant manager and I decided to stay. Yes they gave me an incentive to stay that was competitive with the other offer but I really did not want to leave in the first place because I would be cutting myself and the company short by leaving in the middle of a season. I felt I had to leave just so I could support myself but it would have been unfortunate to leave right in the middle of a season (it felt kind of like quitting half way through a game because you are losing but still believing you could win). How I knew which season I was in was because I had invested a lot of blood, sweat, and tears so to speak in my work at the company and to give up would be to say that was all for nothing other than a paycheck. Plus leaving during a hardship the company was going through would have been to cut my company short of all of the time and energy they invested in me and on the other hand all of my passion I invested in my job there would have been, like I said, for nothing.
So if your career at one company seems like a dead-end or if you think everything is fine and dandy, take a deeper look and try to recognize which season you are in and plan accordingly. If you think you are finishing your season of working at your company, start finding another company to work at before your company decides that for you. That is not to say that companies do not let employees go prematurely, but if you are just getting by from day-to-day, everyone around you probably recognizes that too. So if that is the case for you maybe try transferring to another position in the company if possible or elsewhere. If you feel like you are an asset to the team and they really want you around and your fine with being steady in the same position year after year, that is totally respectable and do not change if you do not want change but if you are getting antsy about if you should stay or move on or you do not like the position you are in or whatever the situation, try to figure out what season you are in before making a decision that you may forever regret.