Essentially, people with shares who want to sell say what the minimum price they will accept is. People who want to buy say what the maximum they will pay is.
At any given moment, the market maker tries to find the price that will result in the maximum number of shares to be sold that satisfies people’s price conditions.
Typically, there will be sellers wanting more than the current price, and buyers who don’t want to pay the current price, so as soon as a suitable matching bid comes in, that can complete the sale.
The bid-ask spread represents the profit the market maker makes on the transaction. The buyer must pay a slightly higher price than the buyer receives.
A market bid just accepts the current price, whatever that is, but that means you could end up with a bad deal if there isn’t a large volume of transactions, so if you can you should use limit orders unless the stock has a high volume and low volatilty, in which case it doesn’t matter much.