Some will buy just because they see the prices going up quickly. Some don't take the time to find out what the company is about and its economic condition. The Bible defines that as being frivolous. There is no specific scripture concerning gambling but plenty of warnings about seeking quick riches and being reckless . A faithful man will abound with blessings, but he who hastens to be rich will not go unpunished.
Some people say the stock market is too unstable and therefore is similar to gambling.
Owning stocks takes patience and fortitude. If that's a weak area for you the stock market can help build up such godly traits. Think on the parable of the money given to three persons with the responsibility to invest it. For the kingdom of heaven is like a man traveling to a far country, who called his own servants and delivered his goods to them. Then he who had received the five talents went and traded with them, and made another five talents.