Atleast buying and selling stock because you think it will go up or go down is gambling. Basically you are betting that you will outperform the market rate.
If you just want to get the market rate of return by passive investing, it is not gambling. This post is talking about trading.
It'd be like saying the foreign exchange market is zero sum, because one party loses HKD and another gains USD. This is obviously flawed because utility is being gained by both parties despite being zero sum in dollars.
If your stock goes up, employee morale is high and ppl want to stay the rest of their vesting schedule. If the stock goes down you have to compensate employees with more cash.
Also, acquisitions are made in stock deals
The secondary market (where people just swap ownership) serves (spikes and manias aside) to reallocate money to more productive companies. This, by the way, is the area that is really suffering under current "only invest in indices because EMH" mantra. My 2c.