The "ten year" rule is not "you're guaranteed to make money in ten years", it's rather that "in a less than ten year period, invest more cautiously, in a ten or more year period, invest more aggressively," because normally 10 years is indeed enough to likely avoid any major crashes.
The 1999-2001 crash was exceptional, but mostly because the 1994-1999 period was also exceptional - the amazing growth of that period (tripling over five years!) caused by both lax regulations around speculation and a lack of understanding of the actual value of tech stocks. Yes, a 1999 investment would have taken a long time to show growth - but a 1997 investment would have been fine (around 700 for S&P, the 2008 crash only barely touched that and very quickly recovered from it to see a reasonable gain from that 1997 investment).
It's very, very unlikely that today is the peak of the bubble, and hence the advice that a ten year horizon is long enough to mostly disregard that possibility - and I can tell you that there were tons of people in 1996-1997 warning of the bubble (that was, of course, actually a bubble!) who, if you listened to them, you still lost out on tons of gains.
A 10-year rolling return chart is the better way to visualize this to fully understand what's happening here - in particular due to the insane growth in the 1990s making it very hard to see what happened in the prior periods (all of which are consigned to a more or less straight line on the S&P price chart due to resolution). And to add to that, recognize that the strategy for retirement would be to start moving out of the stock market around 10 years before retirement, with a more aggressive move out at 5 years - so even if you were heavily in stocks and retiring in that 1999-2008 period, you'd still be selling a ton of stocks at a gain during the peaks.
The real lesson is "don't plan to sell everything at once" - have a multi-year plan to slowly move from stocks to more safe investments.