Locks arise from fragmentation: venue A bids 20.00 while venue B offers 20.00, and the two orders never meet because they live on different books. US rules prohibit displaying a quote that locks another venue, so routers must take the contra rather than post into it.
Brief locks still occur during fast moves and are usually resolved in milliseconds, either by someone taking the liquidity or by the quote being cancelled.
Example: NBBO shows 20.00 bid / 20.00 offered. A trader on venue A could sell at 20.00 to the bid or buy at 20.00 from the offer; anyone posting a new bid at 20.00 on a third venue would be locking and must instead route to take. Zero spread looks free, but the size at each price may be only a few hundred shares.
Related: crossed-market, nbbo, protected-quote, order-routing