Warren Buffett and Berkshire Hathaway have made a name for themselves as some of the best investors ever. As a result, the company has gained a significant following that likes to imitate its trades.

While no one should just follow anyone's moves in the stock market unquestioningly, it's useful to look at what Berkshire owns to understand what management thinks will be a winning investment. After doing that, I've spotted two companies investors can buy confidently, and one they should avoid.

Visa

Buffett is a huge fan of toll-booth-style companies. The business model is fairly simple: Create an infrastructure and take a bit of revenue from everything that passes through it. Perhaps one of the greatest toll-booth model businesses of all time is Visa's (V -0.23%) payment processing infrastructure.

Every time a Visa-branded card is swiped, the company collects a small fee for using its network -- and it adds up. This has been incredibly profitable, with Visa consistently posting some of the highest profit margins of any company.

V Gross Profit Margin (Quarterly) Chart

V Gross Profit Margin (Quarterly) data by YCharts

Few companies can transform more than half of every dollar in revenue into net profit, but that's what Visa does. Furthermore, Visa is still posting solid growth despite being as large as it is. In Visa's fourth quarter of fiscal 2023 (ended Sept. 30), its revenue rose 11% to $8.6 billion -- a new record high.

Despite its top-tier business model and strong growth, Visa trades at 32 times trailing earnings and 27 times forward earnings -- some of the lowest levels investors have seen during the past five years. This creates a strong buying opportunity, and while Berkshire may not consider the stock cheap here, it still looks like a bargain from a long-term perspective.

Amazon

Although Berkshire doesn't own much Amazon (AMZN 3.43%) stock, it is a great buy now. Amazon's business has dramatically improved under the leadership of Chief Executive Officer Andy Jassy, who took over from founder Jeff Bezos in 2021.

Under Jassy, Amazon has discovered something that eluded Bezos-led Amazon: Consistent and growing profit. Amazon has been focused on improving its profitability lately, which showed up in 2023.

AMZN Gross Profit Margin (Quarterly) Chart

AMZN Gross Profit Margin (Quarterly) data by YCharts

Amazon's revenue growth has also bounced back, rising 13% in the third quarter. Amazon is a company that's firing on all cylinders right now, and even though Berkshire Hathaway reduced its position in Q3, I think Amazon is a great buy right now.

Apple

Apple (AAPL -0.35%) is undoubtedly Buffett's and Berkshire's favorite stock. It makes up nearly half of Berkshire's portfolio (currently about 47%).

However, this could be an issue in 2024.

While Apple's stock did well in 2023 (it rose 48%), the business struggled.

Apple reported declining revenue every quarter in FY 2023 (ended Sept. 30). This weakness wasn't limited to just one product line, and iPhones, Macs, and iPads all struggled during various times of the year.

When a company struggles, yet the stock doesn't budge or rises, this is a tell-tale sign of overoptimism. This can lead to a bubble and cause serious losses when it bursts. While I don't think Apple is in a bubble quite yet, it's valued at 32 times trailing earnings and 29 times forward earnings estimates -- an expensive price tag for a shrinking company.

So, while Apple may be Berkshire's favorite stock, it's far from a buy right now. The other two companies above are in a much better place than Apple, so investors should look to those if they're trying to stick with Berkshire-owned stocks.