There are many ways to invest in a company depending on how it is structured and whether it is a publicly-traded company or not. The most common way to invest in a company is to buy its shares traded on a stock exchange.
The stock market brings together people who want to sell stock with those who want to buy stock. When you buy share (also called stock) in a company, you receive a piece of the company and become a part owner.
You can learn more about buying and selling stocks here.