A market order is an order to instantly buy or sell at the best available price. It is executed based on the limit orders that are already located in the order book, meaning that market orders depend on market liquidity to be completed.
Since market orders are executed right away, your market order will match the best limit order available on the order book. In other words, if you create a market buy order, it will match the best limit sell orders at the current price. However, if the cheapest limit sell order available is not sufficient to fill your entire market order, your order will automatically match the following limit sell orders until it is finally completed. This process is called slippage and is the reason why you pay higher prices and higher fees with market orders when compared to limit orders.
Market orders are convenient in situations where getting your order quickly filled is more important than getting a certain price. This means that you should only use market orders if you are in a hurry and willing to pay higher prices and fees (caused by the slippage). In other terms, market orders should only be used if you want to buy or sell as quickly as possible, regardless of price and fees.