A market order prioritizes speed over price. It takes whatever is on the other side of the order-book: the ask if buying, the bid if selling, then the next levels if your size is bigger than what is quoted.
It guarantees a fill in a normal market but not a price. In thin or fast markets the slippage can be large.
Example: you send a market buy for 2,000 shares. 800 fill at $15.10, 700 at $15.12, and 500 at $15.15. Your average is $15.12, above the $15.10 you saw on screen.
Related: limit-order, slippage, fill, bid, ask