When you buy a share on the stock market, you aren’t buying it directly from the company, you’re buying it from an existing shareholder. And once the transaction is complete (in the UK there’s a 2 day settlement period) you become a shareholder.