The underlying error is about sample size, and Tversky and Kahneman named it precisely. Their subject was what they called the law of small numbers, the belief "that the law of large numbers applies to small numbers as well." Large samples really do come to resemble the population they are drawn from; that is a theorem. The intuition wrongly extends the guarantee to short runs, and once a short run is expected to be representative, any deviation in it looks like something that must be undone. The gambler's fallacy is that expectation applied forward in time.
Its mirror image is recency bias, and holding the two together is the most useful thing on this page. Recency bias reads a run as a signal that the run will continue, so a good three years means expect a good fourth. The gambler's fallacy reads the same run as a signal that it will reverse, so a bad three years means expect a good fourth. They are opposite forecasts produced by the same underlying mistake, which is treating a short stretch of a noisy series as though it carried more information than it does. Neither is a reading of the evidence; both are ways of not needing one. A reader who has decided that recency bias is the error to avoid, and who therefore bets against whatever has recently happened, has adopted the gambler's fallacy in its place.
The financial version needs one honest qualification that the coin case does not. A coin's flips are independent by construction, so the fallacy is demonstrably a mistake there. Whether stock returns are independent across periods is a genuine and long-running empirical question, and this page takes no position on it. That is exactly why the fallacy is defined by its reasoning rather than by its conclusion. Someone who buys after a fall because the valuation is now attractive on evidence they can state has made an argument that may be right or wrong. Someone who buys because the fall makes a rise "due" has made no argument at all; they have asserted an entitlement to a correction, which is the thing Tversky and Kahneman identified. The conclusion can be identical and only one of them is a fallacy.
Two shapes it takes with money, both of which involve committing more. The first is averaging down on a losing position on the strength of the loss itself, which increases the size of the position at the same time as the reasoning behind it weakens. The second runs the other way, treating a stretch of good years as debt that will be called in, and reducing risk not because the plan changed but because the good years feel used up. Both convert a feeling about a short sequence into a change in exposure.
Knowing about it does not dissolve it. Tversky and Kahneman were explicit that "related biases, such as the gambler's fallacy, survive considerable contradictory evidence," and their paper is largely about professional researchers making the error while knowing the statistics. What actually interrupts it is a rule decided in advance, because a rule does not have to be re-argued at the moment the run feels longest.