Investing guru Warren Buffett may be a living legend, but he's as human as any of us and has admitted to making mistakes.

His holding company Berkshire Hathaway (BRK.A -0.28%) (BRK.B -0.68%) sold off its shares of retail giant Costco Wholesale (COST 0.17%) in the 2020 third quarter, about a year and a half ago. Costco's share price has boomed since then, gaining around 80%.

Does that mean the Oracle of Omaha made a mistake? It's not that simple.

A person grabbing an item from a store shelf.

Image source: Getty Images.

How Costco fits Buffett's investing thesis

Warren Buffett is known for investing in undervalued, easy-to-understand businesses with great fundamentals. He originally bought Costco shares in 1998, when they cost around $28 (adjusted for stock splits) and were trading at a price-to-earnings (P/E) ratio of around 30.

Clearly, at the time, the shares were undervalued. When Berkshire sold its Costco stock in 2020, it had gained nearly 900% over the 20 years of ownership.

Buffett didn't explain why he sold Costco at the time, and he doesn't typically offer explanations for his investing decisions. Over the years, however, he has extolled Costco as a company several times. At the 2018 Berkshire Hathaway annual meeting, he said: "Costco has an enormous appeal to its constituency. They...surprise and delight their customers. And there is nothing like that in business. You have delighted customers, you're a long way home." Buffett's right-hand man Charlie Munger also sits on Costco's board and personally owns more than $90 million worth of Costco stock.

There are several reasons why he might have sold the stock. Its price has increased at a faster rate than its earnings, and its P/E ratio has steadily increased to 45, where it is today. Costco stock may be worth some premium, but Buffett may have decided that at that price, it's no longer undervalued relative to its future earnings or cash flow generation.

He may also have simply decided that other investments offered more potential at that point. During the same quarter that he and his investing managers exited the Costco position, they took positions in six new stocks, mostly in the biotech category.

While Buffett hasn't made it known that he has any regrets about Costco, he has said he regrets selling some of the company's Apple stock at the end of 2020. Apple is Berkshire Hathaway's biggest holding, worth $120 billion, and he said the sale was probably a mistake.

Should you buy Costco?

What does that mean for the individual investor? Costco has been posting outstanding performance since the pandemic started. It has continued to keep it up even as people have resumed many pre-pandemic behaviors, and other companies have seen their inflated growth begin to decelerate. In the second fiscal quarter (ended Feb. 13), sales rose 16% year over year and earnings per share increased from $2.14 to $2.92.

Costco has several competitive advantages, such as its fee-based model that makes for a superlative cash flow system and razor-thin margins that encourage high volume. It performs extraordinarily well under adverse circumstances, which is why it posted higher-than-normal growth when the pandemic started, and is still posting double-digit growth in this inflationary environment.

Its valuation has increased as the stock price has grown, and investors are questioning whether it's worth the premium at this price. That might mean there could be some pullback in the near future, but Costco stock has a lot to offer long-term, and individual investors should consider having it in their portfolios.