You're buying something of value and you might be underestimating or overestimating the value of that thing but you're still getting the thing. Specifically you are buying ownership in a company.
That's not gambling. You don't get paid based on the outcome. You get paid based on the relative value of the company.
Now if that system isn't working very well for you no shit, we have been deregulating markets for the last 50 years what the fuck did you expect? But that's not a problem with the underlining system that's you refusing to do the maintenance the system needs to function properly. If you stop changing your car is oil it's going to break down.
Gambling is when you are paid based entirely on whether a predetermined outcome happens or not. That is definitely what gambling is. You do not own anything. So you only get paid if the event happens. And there is a specific event that has to happen for you to be paid. That is gambling.