Millions of investors buy and sell stocks on public exchanges every business day. But if you ask many of them about the mechanism by which their trades actually happen, few would be able to answer. Below, you'll discover the mechanics of stock market trading and what happens when you press the trade button.

Auction markets
The New York Stock Exchange and several other large exchanges around the world use an auction-based system to facilitate trading. Typically, buyers place bids and sellers post offers for what they'd be willing to accept to trade shares of stock. When buyers and sellers agree to a price, the trade goes through. On the NYSE, dealers known as specialists can step in to enhance liquidity and to smooth out short-term price disruptions due to news or other unforeseen events.

Sometimes, investors place market orders, effectively saying that they're willing to trade shares at any price. In that case, your broker looks at the outstanding order book and picks the most favorable trade to make. The advantage of market orders is that they always go through, but limit orders ensure that you'll never get blindsided by a price that's far different from what you expected.

If your broker is a member of the stock exchange, then it can execute trades directly on your behalf. If not, your broker will typically have a relationship with a member of the exchange, to whom it will pay a fee in order to execute your trade.

Dealer markets
By contrast, the Nasdaq Stock Exchange is a dealer market. Unlike the auction market, in which individual buyers and sellers link up directly, trades in a dealer market always involve buying from or selling to a dealer known as a market-maker. Market-makers are required to list prices at which they'd be willing to buy or sell the stocks they cover.

On the Nasdaq, competition helps keep market-makers in line. Multiple market-makers will cover most stocks, and so they will fight with each other to boost their trade volume and reap more income from their trades. The result is that spreads between what market-makers will pay and what they charge those who are selling their stock to them generally stay relatively narrow.

By understanding market mechanisms, you can avoid some of the pitfalls that inexperienced investors experience. Stock exchanges aren't perfect, but they do a good job overall in helping people invest.

This article is part of The Motley Fool's Knowledge Center, which was created based on the collected wisdom of a fantastic community of investors. We'd love to hear your questions, thoughts, and opinions on the Knowledge Center in general or this page in particular. Your input will help us help the world invest, better! Email us at [email protected]. Thanks -- and Fool on!

Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.