Stocks tend to decline much faster than they rise, often erasing months of steady gains in a matter of days. As the old Wall Street saying goes, "The market takes the stairs up, but the elevator down."

Investors who have long time horizons and diversified portfolios don't need to fear these slumps. They are temporary, after all. Yet it can be helpful to your returns (and your peace of mind) to own a few businesses that do well even when economies are contracting.

With that goal in mind, let's look at two stocks that seem attractive as investments today. Read on for good reasons to like Costco Wholesale (COST 1.01%) and Procter & Gamble (PG -0.78%) if you're aiming to add some stability to your portfolio.

1. Costco

Costco has an excellent track record when it comes to achieving growth through downturns. Shoppers flooded its aisles at the beginning of the pandemic, for example, to stock up on consumer essentials like toilet paper and groceries.

Demand for these products doesn't evaporate during an economic slump as it does for niches like housing and vacation travel. Yet the warehouse retailer is just as popular during economic upswings, too, as evidenced by its soaring growth in fiscal 2021.

There's another big reason to like Costco stock as a stabilizing force in your portfolio. The company gets most of its earnings from membership fees rather than retail sales. Those fees are highly predictable given that over 90% of members renew each year. As a result, while peers like Target and Walmart can show wild profit swings when consumer demand is shifting, Costco tends to keep steady.

Chart showing Costco's operating margin lower than Walmart's and Target's since 2014.

COST Operating Margin (TTM) data by YCharts

The stock is rarely cheap, and right now investors are paying a significant premium for its shares compared to retailing peers'. You'll be glad you shelled out a bit more, though, to have Costco stock in your portfolio during turbulent times.

2. Procter & Gamble

Procter & Gamble has seen many market disruptions since its founding in 1890, and it has always followed them by setting new highs for the business. The maker of hit global brands like Tide detergent and Bounty paper towels is an unusually reliable dividend payer, too. It has hiked its annual payout in each of the last 66 years, in fact.

Investors will love having that income when markets turn lower. They'll also benefit from the industry leader's dominant market position. Consider that P&G boosted organic sales by 7% this past year, even as people became more price sensitive. In comparison, rival Kimberly-Clark (NYSE: KMB) is growing at a more modest 5% rate.

P&G also delivers much higher profitability, with operating income consistently landing above 20% of sales compared to Kimberly-Clark's 14% rate.

As with Costco, you'll pay a premium to own P&G stock right now. Shares are going for nearly 5 times sales compared to Kimberly-Clark's price-to-sales ratio of 2. Yet that elevated price comes with valuable assets like earnings stability, a host of market-leading consumer brands, and a steadily rising dividend. It's hard to put a price on peace of mind like that, especially when a market downturn strikes.