The stock market (also written stockmarket) is the whole system of exchanges and other trading venues where shares in companies are issued and bought and sold. How these markets work is explained in full on the Stock Exchange page.
New shares are sold in the primary market, for example through an IPO, and then trade between investors in the secondary market. Its overall level is tracked by indices such as the S&P 500.