It should come as no surprise to anyone that the stock market can be volatile at times. Wild swings happen, testing investors' emotions when they need to stay calm above all else. 

When everyone around you is panicking, owning shares of resilient, high-quality businesses should help you sleep well at night. Costco (COST 1.01%) is one such company. 

If the stock market crashes, here are three reasons why you should buy shares in this leading retailer. 

Person with hands on head in distress looking at falling stock chart.

Image source: Getty Images.

1. Recession-proof business model 

Costco's business thrives in both good and bad economic times. To prove this point, all we have to do is look at the company's performance over the past year. 

The coronavirus pandemic gave Costco a boost, as consumers frequented warehouses to stock up on essential goods, such as toilet paper, cleaning supplies, and food. Revenue growth percentages were in the double digits in Q4 2020, Q1 2021, and Q2 2021. In a time of heightened economic uncertainty, Costco was increasingly used as a one-stop-shop for people wanting to buy everything they needed without going to multiple places. It was a mission-critical retailer. 

And based on the recent Q3 results, Costco seems to be doing even better today. The now-strong economy, with gradual reopenings happening across the country, helped increase Costco's sales by 21.7% from the prior-year period. Same-store sales (or comps), adjusted to exclude the effects of gas prices and foreign exchange rates, jumped 15.1%, driven by e-commerce gains of 38.2%. 

There's no slowdown happening, at least not yet. 

2. Memberships drive repeat business 

As of May 9, Costco had 109.8 million cardholders, which is up from 108.3 million in the previous quarter. These shoppers paid the company $901 million in membership fees during Q3, a nearly 11% jump from the Q3 2020. 

You must be a member to shop at Costco. Therefore, generating these valuable fees allows the company to keep prices low for its customers, and that drives loyalty. The renewal rate in the U.S. and Canada stood at 91% in the most recent quarter, while globally it was 88.4%. 

From the consumer's perspective, it's quite a remarkable value proposition. For the annual price of $60 (Gold Star membership), you get to shop for high-quality items that are priced cheaper than anywhere else. The shopping experience is made better by great customer service and a treasure hunt atmosphere, encouraging frequent visits. 

While membership fees only accounted for 2% of overall sales in the quarter, they drive repeat business. Costco stays top-of-mind for these customers who view the membership fee as a sunk cost, leading to more visits. 

In the next market crash, this type of dependable consumer behavior is what you want from the companies you own. 

3. Powerful competitive advantage 

The most important determinant of a high-quality business is the presence of a competitive advantage. 

Costco has a strong and enduring moat that stems from scale advantages. Its sheer size, with 809 total locations and $163 billion in sales last fiscal year, makes it the third-largest retailer in the world. This gives the company massive negotiating power with its suppliers, savings the company loves to share with its loyal customer base. 

"Price is at the top of our list. When prices are going down ... we want to be the first to go down," CFO Richard Galanti said in 2018 when discussing the company's strategy. This makes it extremely difficult for rivals to compete with Costco, whose primary goal is to drop prices as low as possible. 

Adding to Costco's success is the rise of its private label brand, Kirkland Signature. Customers have come to expect these products to be of the same or even better quality than prominent national brands. Put everything together and it's easy to see why Costco has been so successful throughout the years. 

Investor takeaway

Investing in Costco stock can be a lucrative decision if the stock market crashes. The business is recession-proof, attracts members who visit often, and possesses a strong competitive advantage built on its massive scale. This is the security you want in volatile times.