​​We're days away from the end of 2021, and the S&P 500 has put on a master class in outperforming expectations. Even with its pullback in recent days, the broad market index has gained nearly 30% this year, more than double its long-term historical average.

Yet that just means we're another day closer to the inevitable market correction. Just as night follows day, a stock market crash is inevitable because market declines are a natural part of the normal business and investment cycle. No one can forecast exactly when it will strike, but smart investors realize it's best to prepare for the eventuality.

Person holding head and staring at laptop.

Image source: Getty Images.

For as long as people have been investing, stretching even as far back to the Dutch tulip mania in the 1600s, busts have followed booms. And what a boom we've enjoyed! Since the bottom of the Great Recession, the S&P 500 has quadrupled in value.

2020's pandemic-driven 34% drop in the stock indexes within the span of just a few weeks was the worst on record. But savvy investors don't have to worry. These events are not a problem when you're invested in the right companies. Being prepared for the worst and hoping for the best means when the next stock market crash or correction occurs, you'll want to have your money invested in stocks that will help lead the way forward. Here are two tech stocks you'll want to buy.

Listening to music on headphones.

Image source: Getty Images.

1. Apple

The burden that inflation is imposing on consumers also poses a threat to some of the biggest, best-run businesses, like Apple (AAPL 0.66%), which is currently benefiting from the smartphone upgrade cycle and the rollout of 5G network infrastructure. Any attempt by the Federal Reserve to raise interest rates to contain runaway inflation could cause an economic slowdown by making money more expensive to borrow. Stock valuations would also turn lower.

That's not necessarily bad news for investors who might find Apple's $2.8 trillion valuation a bit rich to buy into at the moment. The stock trades at 30 times trailing earnings, or about double its typical multiple. A correction would bring Apple back into the realm of the attainable, even as its business continues jogging forward.

Sales of the iPhone 13 are outpacing those of the iPhone 12 at the same time, but Apple reportedly warned suppliers that demand is waning as the calendar year progresses. It's not necessarily for a lack of consumer desire, but rather the global supply chain constraints that have made it difficult to find the product. Apple previously cut its iPhone production target by 10 million units from its original goal of 90 million.

Analysts think many consumers may choose to forgo the iPhone 13 and wait for the next upgrade. Coupled with a market crash, that could put Apple stock at a very attractive entry point with pent-up demand for the next iteration of the iPhone.

People checking network servers.

Image source: Getty Images.

2. Amazon

Few companies are as essential to the working of the U.S. economy as Amazon (AMZN -1.40%). It will account for 41.4% of all online spending in the U.S. this year, according to eMarketer estimates. At the same time, Amazon Web Services (AWS), its cloud infrastructure business, is on track to generate over $60 billion in annual revenue in 2021 based on its year-to-date performance. The company is responsible for thousands of web-based businesses and the federal government's ability to remain online, making Amazon crucial to a well-functioning economy.

That won't change if the stock market collapses. Its share of U.S. retail e-commerce sales will be more than 50% larger than the shares of the next nine e-commerce companies combined. Amazon's piece of the online market is nearly six times more than Walmart's second-place share at just 7.2%, and 10 times greater than third-place eBay. E-commerce data tracker Edge by Ascential expects Amazon will see $26.7 billion just in online grocery sales five from now years, or nearly double its current amount. 

Amid rising prices and supply chain woes, Amazon has become a lifeline for many, and that will continue long after any financial restructuring. The stock gained 76% during the first year of the pandemic and took a breather during the reopening of the economy. Amazon shares have been relatively flat all year long. A correction would allow investors to buy a tech stock at a more reasonable valuation even as its crucial role only gets reinforced.