Back when I was a flag aide, I was lucky enough to accompany my boss on a few trips to hear a guest speaker. Since we worked (in part) for NATO ACT, we were lucky enough to sit in on an industry speaker, which on one occasion was from IBM.
The female speaker was an engineer that had moved into management, and talked about how IBM develops personnel. What amazed me was the high level of employee turnover every year (something crazy like 15%) and yet a nearly constant level of revenue from IBM despite drastic changes in the technology market. She talked to us about how IBM has to constantly reeducate it's workforce, shift to new areas, and grow new industries.
One particular story stood out. The speaker was given an assignment outside of her comfort zone, which in her words "nearly killed her." Yet, in the end, she said it was the best learning experience for her because it caused her to think "outside the box."
The similarities to the Navy are many. We dump a lot of folks after their initial commitment, and have to constantly train people to new missions and new tasks. And yet how many officers stop learning after college? How many sailors don't read anything new? We too often view education like a flu shot...painful, but over in a minute and then move onto something else, when in reality education is a continual process over our entire lifetime.
Instead of viewing your career as moving from milestone job to milestone job...how about making a list of what skills you plan to acquire in each job. Then think about what skills your department head, XO and CO have. If you aspire to those positions, look at what areas you lack in and take jobs or get education to fill in those gaps.
That way, if you're lucky enough to fill that XO or CO job, you can be ready to do so.