A market order instructs a broker to buy or sell a stock immediately at the best price currently available, with no price limit specified. It prioritises speed and certainty of execution over price: the order will fill, almost always within moments, but the exact price isn't guaranteed in advance.
For a heavily traded stock in normal conditions, the difference between the price you saw and the price you actually got is usually negligible. For a thinly traded stock, or during a fast-moving market, a market order can fill at a noticeably worse price than expected — a gap known as slippage, because the order works through the available quotes at each price level until it's filled, and a large order can move through several levels.
The alternative is a limit order, which trades certainty of execution for certainty of price.