Startups require crazy hours and solid dedication. If you put that into a career at a big software company, even with average talent, you will reach the level which yields that kind of money.
A) actual, i.e. what you've built or
B) potential, i.e. what will you build
And then to get rich you need a multiplier on those things. But just being a good engineer, in general, does not get richly rewarded. If you show me a pure engineer who makes 1 million, I can show you a founder who made 100x from his work.