3 Things That Separate Trading/Investing From Gambling
1-Dividends: When you're playing roulette it's unlikely the house will throw in a chip or two back to you every few bets, in markets there stocks with consistent dividends such as GE with consistent dividends dating back to the 1890s.
2-50/50 or better odds: Even if you are clueless with stock trading and take random bets without any technical or fundamental analysis your odds of getting a trade right or losing principle is 50/50. There are small comissions but on a decent sized account it's miniscule.
3-Indicators and analysis: In minor ways this becomes apparent in gambling too but not to the same extent. For example in the game '21' card counting can lead to 52% win chances if a deck has gone through a certain series of cards already. In the markets some experts have achieved as high as a 70% win ratio such as Jim Simons world famous Renaissance fund. This is due to intense mathematical analysis by himself and his team.