Gambling has a bad reputation for several reasons: its addictive quality encourages bad behavior, it takes place in unsavory places full of other vices, and the house edge means it's a reliable way to stochastically lose money.
The last two don't apply to playing the stock market, so we're left with it being addictive. A lot of drugs and behaviors are addictive, and in all cases there are users who are, nonetheless, not addicted.
So caution is still indicated, but the situation is not as pessimistic or as inevitable as you paint it to be.
In particular, losses are not inevitable. In a bull market, there will be more gains than losses, by definition, in a bear market, the opposite.
The market is more bull than bear, fairly consistently, due to a combination of inflation and economic growth. Past performance is not indicative of future results...