The price of a stock is determined by supply and demand.
If more people want to buy a stock, demand goes up, and the owners are able to ask for and receive a higher price when they sell.
If fewer people want to own the stock, demand is low, and sellers will settle for lower prices to get rid of the stock.
Supply and demand affects the stock market by determining prices of the individual stocks that make up the market.
This is when the companies purchase their own shares at market prices, retire these shares and so decrease the number of existing shares overall.