The advice goes against Joseph de la Vega's first two rules (and arguably against the third which is somewhat similar to the second, too).
That being said, regularly investing in stocks is reasonably safe if you have a sufficient remaining life expectancy, if you do not ever actually need money, and if there always remain enough greater fools.
As de la Vega already pointed out three centuries ago, guessing right is witchcraft and you cannot rely on your luck lasting, so you should seize what you can get when you can get it.
Constantly reinvesting in the market is the exact opposite of that. You never realize wins (or losses) so in theory you keep making profits, but in reality you have nothing. All your profits are of theoretical nature until the moment you actually realize them. Now of course, greed tells you that there is always room upwards for some more, so...
Factually, you have the worthless promise of an entirely non-trustworthy party (they wouldn't emit stock shares if they were trutsworthy enough to get the money otherwise) and you own, in theory, a small share of, well... nothing. If the company goes bankrupt, the promise goes up in smoke. And, you hope that someone else is an even greater, more greedy fool, and that this someone will eventually give you more money for the worthless shares than you paid in the first place. Money out of nothere!
Greater fools is not something I made up, this is how the stock market works, and has always worked since the very first stocks. Stock market can be considered a completely legal Ponzi scheme, if you care to look at it that way.
Someone gives a promise, and some fools believe that they can get rich, so they give him money. Some other fools want to get rich too, but are too late, so they buy from those having bought earlier (for a higher price). Prices flucutate a bit depending on demand, but the general tendency is "upwards" as there are always more fools who want to get rich.
Insofar, the recommendation "keep investing" is not at all surprising because only if you (and hundred thousands of others) actually keep investing, the people who made this recommendation make money! If nobody keeps buying, prices don't go up!
But sometimes, the assumption that people just keep buying doesn't hold, and like in every Ponzi scheme, the very last fools will lose their money. Those earlier in the cascade who bought (and sold! important detail!) early enough will still have made a profit from those last fools. An index certificate is somewhat safer than individual stocks insofar as one company getting in trouble or going bankrupt (which does happen) doesn't mean everything is just gone.
Nevertheless, it doesn't even have to be an event like a war, a global crisis, or a company going bankrupt. Stock markets get unstable when there's something like a corona virus epidemy, too. Oh heck, greed already makes people entirely moronic when some company makes a press release with meaningless buzzwords and ridiculous claims or when some analyst thinks that some company may only increase their profits by 9.8% instead of 10% this year.
And, there are even automated mechanisms (intended to limit/prevent losses, ironically) that can, under circumstances that you cannot foresee, kick off an avalance for ridiculous things like this.
If you are confident that you can comfortably sit through whatever bad times may come unexpectedly (and these may possibly last 10-20 years) that's fine. If you need money in the mean time, for whatever reason, well... that's bad luck for you. In that case you've been the fool paying the not-so-foolish fools.