With the share market we are believing some third parties for our profits whereas in gambling, we are relaying on our own skills to make profits. I do believe on my own capability for my fortunes than others.
In stock market, you can rely on professional fund managers to manage the money for you. But those manager on average will be worse off than the index track funds.
In gambling, only very few professional gamblers can make a living. Most of the gamblers can only have fun, not the money.
I think it's a matter of perspective actually. By buying a stock of a company you're putting your money in the hands of the company's board and CEO. If you bet in a sportsbook you just placed your money in the hands of the team and the coaches. Both have risks and rewards, it's just how you look at it.