What is Stock Trading?
If a company becomes public it will partake in an IPO (initial public offering). The shares of the company can then be traded on an exchange.
Exchanges offer a place for buyers and sellers to transact at a price determind by supply and demand. They are in fact, secondary markets. Existing owners of shares can transact here with potential buyers.
Corporations listed on exchanges do not buy and sell their own shares (*except for stock buybacks and issuance of new shares).
Therefore if you trade a stock on exchange you are not buying it from the company directly. Instead you will transact with an existing shareholder, who wishes to sell.