Market orders do not get priority over limit orders. Time is the only factor that matters in price/time order matching when the order price is the same.
For example, suppose the current best available offer for AAPL is $100.01 and the best available bid is $100.00. Now a limit buy for $100.01 and a market buy arrive at around the same instant. The matching engine can only receive one order at a time, no matter how close together they arrive.
Let's say that by chance the limit buy arrives first. The engine will check if there's a matching sell at $100.01 and indeed there is and a trade occurs. This all happens in an instant before the matching engine ever sees the market buy. Then it moves on to the market buy and processes it accordingly.
On the other hand, let's say that by chance the market buy arrives first. The engine will match it with the best available sell (at $100.01) and a trade occurs. This all happens in an instant before the matching engine ever sees the limit buy. Then it moves on to the limit buy and processes it accordingly.
So there's never a comparison between the two orders or their "priorities" because they never exist in the system at the same time. The first one to arrive is processed first; the second one to arrive is processed second.