Billionaire investor Warren Buffett is one of the richest people in the world. But that doesn't mean every stock he buys is a winner. His company, Berkshire Hathaway, has gone through many stocks over the years.

Two companies that it still owns shares of that investors might find perplexing are Kraft Heinz (KHC -0.55%) and Bank of America (BAC -0.21%). Neither has performed well over the past five years. Should investors avoid these stocks, or could they be good buys at their reduced valuations?

1. Kraft Heinz

Consumer goods company Kraft Heinz is known for having strong brands in its business. Kraft and Heinz are already common names in many pantries across the U.S. Philadelphia, Jell-O, and Kool-Aid are examples of many other well-known brands that Kraft owns and that are popular food options at grocery stores.

That brand power has enabled Kraft's business to perform reasonably well amid inflation. It's able to raise prices and not suffer from a significant decline in volume.

But one thing that the business isn't known for is being a great investment. While Kraft Heinz is one of Buffett's top holdings, it has been one of Berkshire Hathaway's worst investments.

Over the past five years, the stock has declined a mammoth 39%. Even if you include its dividend, its total return is still a negative 23% overall. The S&P 500, by comparison, has generated total returns of 73% over the same stretch. 

Writedowns totaling $15.4 billion in 2018, an investigation into its accounting policies, and a dividend cut are just a few of the reasons investors haven't been thrilled with Kraft's stock in recent years.

Today, Kraft's business looks to be in better shape, with the company reporting 7.3% sales growth for the first three months of the year. For 2023, it's anticipating organic net sales growth of between 4% and 6%. Thanks to the declining share price, the stock also offers a relatively high dividend yield of 4.3%. And while the payout ratio is a bit high at over 80%, it still looks to be sustainable given the company's continued growth.

At 19 times trailing earnings, Kraft's stock is trading in line with the S&P 500 average. Although there's some risk here, this can be a good option for income investors. The company's brands are demonstrating resiliency, which can lead to stronger results, better future returns, and a safer dividend.

2. Bank of America

Bank of America is a top bank stock, but over five years, its returns have been flat. The saving grace is that with its dividend, investors would still be up 11%. That's still nowhere near the S&P 500's performance, but at least it's not a negative return overall. 

Unlike Kraft Heinz, Bank of America stock has done fairly well with respect to the markets. Where it began to diverge with the S&P 500 was at the start of 2022, when interest rates were rising, inflation became a problem, and the outlook for the economy as a whole became bleaker. 

Investing in a big bank normally makes for a sound long-term investment. Unfortunately, the highly publicized failures of First Republic and Silicon Valley Bank have only turned investors more bearish on bank stocks this year.

Bank of America, however, is one of the safer bank stocks to own.

During the first three months of 2023, even as the bank increased its provision for credit losses to account for a worsening economic outlook and a higher risk of defaults, its net income still totaled $7.7 billion and rose 16% year over year. Despite rising expenses, the company's net interest income jumped by 25% to $14.4 billion.

Trading at less than nine times earnings, the stock is a potentially cheap buy right now with a good margin of safety for long-term investors. This is another example of a stock that may not have done well over the past five years, but that could produce much better returns in the future with a low valuation.