Not just stock, all transactions are zero sum.
If someone sells you something and the value goes up, he’ll lose out on money and you get some. If price goes down, you’ll lose money and he’ll dodge a bullet.
Now the definition of gain and loss in accounting can be different from economics. If you buy something for $10 and sell to me for $15. If I sell it to someone else for $20, we both make $5 in accounting but economically, my $5 gain could have been yours if you have kept it and thus you miss/lose $5 by selling it to me
Latest Answers