The other place a bid or ask can come from are the market makers.
In order to provide continuous liquidity there are market makers for each security. In our example, the market maker ensures that at all times there is a bid and an ask for XYZ stock no matter how many or few people are buying or selling. This is not a pro bono job, the market maker pockets the spread (though in reality this isn't as easy as it sounds).
In the example above, the bid is $49 and the ask is $51 until the investor enters the limit order at $50. But, what if a large seller begins unloading XYZ stock?
Let's say that for the current bid of $49 the buyer is willing to take 500 shares. So, the seller gets $49 per share for the first 500 shares, but if they want to sell more shares then what happens?
If there is another bid, then some shares could be sold at that price. But, what if there are not enough bids to cover the whole amount of shares to be sold? This is where the market maker comes in. The maker might set the bid at $48 for 1,000 shares. If more shares are still coming, the maker can continue to adjust the bids, usually at lower and lower prices until all of the shares are gone.
If, once the larger order is cleared out, the stock works its way back to the previous price, then the maker profits by selling the shares back into the market via the ask. If this is the start of a downward trend for the stock, then the market maker loses money on the shares purchased for higher amounts. Of course, the maker can now profit on the spread at the new level to make up any losses.