The firms that trade in stocks and shares are called Market Makers and Brokers. Brokers act on behalf of customers: they "go" to the exchange (usually electronically or by phone) to buy or sell shares from/to Market Makers. The market makers set the price, and as such are said to "make a market". They will quote both a buying price and a selling price - the two are different and this margins is partly how the Market Maker earns their profits.
The prices quoted are kept in check because market makers compete with each other to "make a market" in the popular stocks.
Hope that answers the question. If anyone wants to know more about the Stock Markets and how stocks and shares work, please ask and I'll do my best to help.
Student or Learner