It's decently luck based. You gotta start off by working for a good company that'll give you the opportunities you're looking for.
For example, if you work for a tech giant, much more likely you can just work on something at the top of the hierarchy for a while and rocket your way up. If you work for a start up, maybe the company takes off, maybe not, but there's not much of a ladder for you to climb.
Someone I'm distantly related to (never met him, was just told by my parents) was a VP at a medium sized tech company, making a decent living but nothing amazing. Out of nowhere they decided to go public and he sold his stock and suddenly found himself 10 million dollars richer.
The old Thomas Jefferson adage holds "I find that the harder I work, the luckier I get". There's a lot of luck in life, but outworking your peers is anyone's best strategy even if it doesn't work out 100% of the time.
My general career advice to people is: If you just graduated college, everyone you know under the age of 25 will be enjoying freedom, partying, spending their money on things they couldn't afford before. If you want that, fine, enjoy life cause it's short.
But, under the age of 25 is when you have the most mental acuity. Your brain doesn't stop developing until that age and you still have the ability to install a TON of things that are much harder to incorporate into your natural thinking past that age. I'm a bit older and I already feel like I'm slowing down. My advice is to use that time to work your ass off, say yes to every opportunity, save as much money as you can.
Past that age, you now should have a leg up on most people your age who just weren't willing to put in the work.
Oh also, don't ever underestimate how bad your older coworkers are at using the computer. The easiest way I've ever found to impress older people is just by being good at using a computer lol.
Another story, my friend got a consulting gig making apps for a major food and beverage company. Some 60 year old coworker of his was freaking out cause he really wanted to use his iPad at a meeting instead of his Windows laptop. So my friend made him an "app" that was just a pdf reader and then later that guy ended up showing it off to the VP of the company lmao.
So yeah, it's hard to really just give you more general advice than: keep your eyes open, make work your priority, don't say no to opportunities. You're in the best time of your life to learn the things that'll serve you forever. Most people waste it.