When a company goes public it begins selling shares of stock in a public stock market. This means that it asks for money from investors and gives them a share of the company in return of their investment.
The result is: The company gets the money and the investor gets a share in the company's ownership.The investor gets a share and he becomes the owner of the company but he owns only a part corresponding to the number of shares he buys.