Owning a stock means owning a portion (usually very small) of a publicly traded company. Therefore, if the value of the entire company fluctuates, so will the value of the stock.
When a share's price decreases in value, that change in value is not redistributed among any parties – the value of the company simply shrinks. The stock market is governed by the forces of supply and demand. In other words, it is not a zero-sum game, like gambling in a casino, in which there is an equal loser for every winner, and vice versa.
How a Company's Value Can Shrink
First, we need to understand how a company's value is "created." When a stock's price increases, it does so because there are more people willing to buy the stock (demand it) than people willing to sell it (supply it). This high demand in relation to supply creates value for the stock because buyers must compete against one another for it, and the more they want the stock for themselves, the more they are willing to pay for it.
The opposite occurs when a stock price decreases, which simply results from a low demand in relation to supply. Just as a high number of buyers creates value, a high number of sellers erodes value.
For example, Waste Management Inc (WM) has 434.22 million shares outstanding as of January 2018. If its share price dropped by $1, it would be roughly equivalent to a $434 million loss in (implicit) value.
So even though it might feel like someone is taking your money when your stock declines, the cash is simply disappearing into thin air with the popularity of the stock. However, this decline in popularity corresponds to something tangible — the company's ability to carry on its operations efficiently, which is reflected in its earnings.
Remember, you are part-owner of the company, so if the stock declines, it means you are part-owner of a company that is no longer perceived to be doing a great job of producing something. And, if you want to get rid of this company, you must be willing to sell it for less. Why? Because its inherent value is perceived to be worth less.
Therefore, on a very basic level, a realized loss from a stock is a reflection of the difference between the market's perception of the company when you bought it and the market's perception of it when you sold it.
(For more on this subject, check out When Stock Prices Drop, Where's the Money?)