In the stock market there are market makers. A market maker is in the business of buying stock from people who want to sell and selling stock to people who want to buy. Those people could just trade with each other directly, sure, but that would be inconvenient. You might want to sell now, and I might want to buy in 10 minutes. Rather than wait around, you sell to a market maker now, and she sells to me in 10 minutes. You and I get “immediacy.” In exchange, we pay the market maker a bit of money, in the form of a spread between the price she pays you now and the price I pay her in 10 minutes.
Being in this business, the market maker is exposed to market prices: If the stock goes up over those 10 minutes, she makes a bit of extra money; if it goes down (by more than the spread) she loses money. But in fact the market maker is not necessarily long a lot of stock. For one thing, she trades pretty rapidly — market makers in the US stock market are often called “high-frequency traders” — and so doesn’t hold too much stock for too long. For another thing, she can sell stock before she buys it. This is called short selling. If you want to buy now, and I want to sell in 10 minutes, the market maker will sell you some stock now and buy it from me in 10 minutes. If the stock goes up over those 10 minutes (by more than the spread), she loses money; if it goes down, she makes money. Over the course of a day, the market maker will sometimes buy before selling and other times sell before buying; she will be long some stocks at some times and short other stocks at other times. Overall she is probably close to flat, meaning that she won’t make or lose much money if the stock market jumps up or down.