The stock market is a place that brings together buyers and sellers of stock to effect transactions. Prices are arrived at by true measure of supply and demand, as the bid and ask for each stock constantly change to reflect the supply on the sell or buy side. It no longer needs to be a physical location because of the electronic age.
Buyers and sellers are made up of three distinct camps. This first group is individuals and institutions, which both trade for the benefit of their own portfolio. The next group is broker/dealers who may be representing either of the first group or may be trading for their own inventory, which in turn may be sold to clients down the line. Finally, there is the ever-fading role of the specialist, a stock market pro who used to make the books for stocks and in times of volatility would sacrifice his own capital to steady prices in the stocks he offered. There are still specialists now but they do not have this function for a couple of reasons: 1) they make way less money, 2) the same stocks trade in a variety of locations so he/she cannot control the price and 3) they volume is so high no one individual can afford to balance the flow of orders in volatile times.