speculation, as defined by Merriam-Webster
activity in which someone buys and sells things (such as stocks or
pieces of property) in the hope of making a large profit but with the
risk of a large loss.
This is not a Ponzi scheme nor is it insider trading, both of which are illegal. I interpret the OP's phrase "by accident" as ruling out illegal activity.
This is not the place to write an essay on the role of speculation in the stock market or real estate market or in the economy (even if I were qualified to do so). However, the situation which seems to fit the OP's scenario is that of naïve investors suffering losses on their speculative investments; by the time they become aware that Company XYZ is hot, the more knowledgeable speculators will have decided to take their profits and move on, possibly because they have learned that Company XYZ is not so hot after all. For more about speculation, see below.
From Investopedia, Speculation
Speculation is the act of trading in an asset, or conducting a
financial transaction, that has a significant risk of losing most or
all of the initial outlay, in expectation of a substantial gain. With
speculation, the risk of loss is more than offset by the possibility
of a huge gain; otherwise, there would be very little motivation to
speculate. While it is often confused with gambling, the key
difference is that speculation is generally tantamount to taking a
calculated risk and is not dependent on pure chance, whereas gambling
depends on totally random outcomes or chance
It may sometimes be difficult to distinguish between speculation and
investment, and whether an activity qualifies as speculative or
investing depends on a number of factors, including the nature of the
asset, the expected duration of the holding period, and the amount of