Building life-changing wealth in the stock market requires just two ingredients. First, you need to own a collection of great businesses. Second, you need to hold them for long enough to let compounding do its magic. Sounds easy, right?

The problem is that it can be hard to identify excellent businesses before their stock prices soar. And many investors end up getting rattled by volatility and selling these stocks too soon.

So let's look at a pair of stocks that might help you avoid these common pitfalls. Coca-Cola (KO) and Costco Wholesale (COST 1.01%) both feature market-leading businesses with unusually stable earnings outlooks.

Coca-Cola is unbeatable

One of the key factors that originally attracted Warren Buffett to Coca-Cola stock, its defensible market posture, is still clearly at play right now. The beverage giant's last earnings report revealed that organic sales jumped 16% through June as consumers eagerly purchased its sparkling and still drinks.

Coke demonstrated its pricing power, too, with adjusted operating profit falling just slightly to 31% of sales from 32% a year ago. "Our results...reflect the agility of our business [and] the strength of our streamlined portfolio of brands," CEO James Quincey said in a press release.

Steady market share growth like that will help you keep Coke in your portfolio through the turbulence that might continue as this bear market moves on. And so will its dividend payment, which has increased in each of the last 59 years and currently yields 3.23%. Set those dividends to automatically reinvest and allow any downturn to help you build up a bigger position in this world-class business.

Costco has superfans

Few retailers are as well-suited to these economic times as Costco. The warehouse giant's value proposition is at its highest when consumers are looking for deals. It prides itself on being a price leader, after all, and shoppers are ultra-focused on prices these days.

But Costco generates impressive growth in a wide range of selling environments. It was a key destination in earlier phases of the pandemic when people were stocking their pantries, and the aisles were packed as social distancing efforts were lifted.

The retailer's latest earnings announcement extended this positive momentum deeper into 2022. Sales through late August were up 10% on top of huge gains a year ago. But it is that steady profit growth that has investors even more excited. Annual operating income grew to $7.8 billion from $6.7 billion in fiscal 2022 and will likely continue steadily expanding. Costco earns most of its profit from membership fees, after all.

These income streams are steadier than product margins, especially since more than 90% of the retailer's members renew their subscriptions each year. And the cash delivers an instant earnings spike when Costco raises its fees, as it does about every five years.

The next fee raise is due to happen in the next year or so, and it will likely go over well given how much value the Costco membership is providing in an era of rising prices. But the long-term earnings outlook is similarly bright for this business, and that's the best reason to take a closer look at the stock right now.