Whether or not investing is gambling depends solely on your strategy.
High risk trades are generally considered gambling, such as during squeezes, out of the money options, and during any period you expect numbers to go one way or another in a short period. These are considered gambling if you're chasing large gains quickly and are using large portions of your account.
However, this can still be mitigated. If what you use to get these short term gains is small, small enough that any losses from these are still less than your overall gains, it's not gambling and when used in this way, is similar to how investments such as options trading should be used.
So yes, investing can be considered gambling but only when used for volatile trades with large amounts of money, rather than going for steady and stable increases.