The speed with which stocks have slumped over the past few weeks has taken many by surprise. Just two-and-a-half months earlier, investors had been celebrating a second straight year of blockbuster returns.