Market makers maintain continuous two sided quotes (bid and ask). Let's assume that the market maker is on both sides of the quote. If someone else trades at the market (buy at the ask and sell at the bid), the market maker earns the difference since he is selling at the ask and buying at the bid.
Any trader can offer a better price on the bid and/or the ask than the market maker. They then become the market and replace the market maker in the aforementioned pairing of trades. There have been times with illiquid stocks with a wide spread where I have been the best bid and the best ask, willing to unload at the higher price and willing to buy more at the lower prices. I temporarily became the market maker.
Traders and market maker will not be filled above the ask or below the bid (outside of NBBO) with single transactions. This does not apply to option spreads where the only requirement is to execute at the order's net price (the individual legs can be above or below NBBO).