You seriously need to find out how business and the stock market works.
As a general rule, corporations generated X number of shares during their IPO. Some of those were sold to the public and those shares are now traded, sold, and resold. People buy them because they believe in the company and/or because the company seems to be growing and generally becoming more valuable.
Apple, for example, isn't continually issuing more shares and selling them off. Nor will they go bankrupt soon. They make products and people buy them, and the difference between COGS and the selling price is profit.