I think luck is a big part of it absolutely, I just don't think it's the only piece. But I also know that IME some engineers looking at new roles think about likelihood of company success way less than they should relative to "do I like the technology/culture/whatever" and so it is not surprising if they don't end up at successful companies.
If you hate it there, you'll probably leave and never vest your equity. Even if you hang on and suffer through it to get your equity, it'll damage you in ways that money won't help with.
If you hate it, chances are that everyone else does too, which means the good people will leave and the startup is less likely to succeed even if everything else is good.
Most engineers enjoy interesting challenges, and this can be a big factor in choosing a role. If the startup is providing interesting challenges then it's doing interesting/difficult stuff. This is a factor in success - startups that aren't doing interesting/difficult stuff are easier to copy and have less barriers to entry for competitors.
Even if you don't get lucky and win the equity lottery, you had a good job and probably learned some interesting things.
Regardless, being able to identify "company success" is something that's always been taught as luck/lottery so I'd love to improve my ability here.
I'd say the mid-growth time (series B and nearby but of course depends on the company) is a particularly bad time to join a startup. It is too late to get favorable stock options but too early to tell if it's going to be a home run. So for individual contributors it's pretty much all blind risk with low probability of reward.
Good times to join a startup are very early when the valuation is a couple pennies or less so you can get meaningful percentage of stock and you can early exercise all of it for little money and file 83b.
Or join late in the game startups that are big hits and clearly going to the IPO. Way less stock, but risk of failure is now small.
It's luck, not good judgement. No-one knows how to accurately assess whether an early-stage startup is going to succeed or fail.
If it was possible, accelerators would have better-than-background rates of success. Even YC, who get their pick of pretty much every startup, has barely better than background rates of success.
If it was possible, VC's would have better than background rates of success. They don't. They rely on the successes being much bigger than the failures because the failures are limited by bankruptcy while the successes have no limits.
I think blaming people for being bad at judging early stage startup success likelihood is poor form when no-one else in the entire industry has any idea how to do this.