gambling has negative expected value, the house always wins in the long run.
the stock market has pretty much always trended up over time so if you just buy a bunch of stuff and wait a while you will pretty much always win. (you can still gamble with stocks, it's just that stocks are fundamentally different and you can also not gamble)