Hard work, intelligence, and preexisting resources are typically prerequisites, and then a whole lot of luck comes into play.
I suspect taking their wages in stock wasn't an option actually offered to janitors, and even if it had been, they wouldn't have taken it: unmarketable equity doesn't put a roof over your head or put food on the table. Bezos, on the other hand, could afford to take below market compensation (at least liquidity-wise) because he had a pile of money already from his time in finance.