Buying stock means you are purchasing shares in the open market and becoming a shareholder of that company.
The amount of shares that are available to trade in the open market is called the float but there may be more shares that are held by insiders and employees that are restricted from trading. Companies can reduce or increase the amount of shares available through stock splits.
For example, a company that issues a 2-1 stock split will increase the amount of shares available by two, resulting in the share price being reduced by half. So if Microsoft had 1,000,000 shares outstanding with a stock price of $50 and they issue a 2-1 stock split, they would then have 2,000,000 shares outstanding with a share price of $25.
The reason companies usually do this is to reduce the price of the stock because it has become more expensive than other companies in its sector and less attractive for investors.
One share equals one unit of ownership in a company. So the more shares you own, the more you own of the company. If you own 1,000 shares of XYZ stock and they have 100,000 shares outstanding, then you own 1% of that company.
Generally companies will issue shares to the public so that they can raise money to further business operations or pay down debt, and in return they will work hard to make the business more valuable, resulting in your shares being worth more money.