A lot has changed in the stock market over the past year. Interest rates are higher, the bear market of 2022 is behind us, and stocks are on another bull run. Any time the market sentiment changes, it's common for investors to rethink their investing strategy, especially if it feels like things are no longer working as they used to.

Some companies are worth buying regardless of what the market is doing, whether stocks are on the rise or being sold off. Let's take a look at what makes these three companies worth buying in all market conditions.

1. QuantumScape

As more drivers trade in their internal combustion cars for electric vehicles (EVs), the demand for batteries to power those cars will continue to increase. Currently, EVs use lithium-ion batteries, which have been around for decades and have seen incremental improvements over time, making them more efficient and less expensive.

However, QuantumScape (QS 5.69%) believes the future of EV battery technology is in lithium-metal solid-state batteries and is working with several auto manufacturers to make this vision a reality. These solid-state batteries would provide faster charging and longer ranges for cars and would be safer.

QuantumScape is a pre-revenue company, so any investment at this point is a bet on this technology proving to be economically viable at scale. In this sense, the market sentiment would have little impact on this kind of investment, making it a stock to buy at any point for an investor who believes solid-state batteries are the future of EVs.

While this technology still has a way to go before it becomes mainstream, there are some positive signs. QuantumScape has started shipping prototypes to its auto-manufacturing partners for testing. Interested investors should follow these developments as evidence of the company's progress.

2. Berkshire Hathaway

2023 was a great year for the stock market, with the S&P 500 up 24% on the year. Warren Buffett's Berkshire Hathaway (BRK.A -0.76%) (BRK.B -0.69%) had a respectable year with a gain of 16%, but it did trail the broader market. This, however, should not be a surprise. Berkshire is not the kind of company that will outperform when the market is hot. The reason to own Berkshire is for when the market is struggling.

Let's look at 2022. The S&P 500 had a terrible year, ending down 20%. However, Berkshire Hathaway was up 3.5% in 2022. Over the two years combined, Berkshire is the clear winner.

BRK.A Chart

BRK.A data by YCharts

Berkshire Hathaway provides ballast to a portfolio, and over the long term, it has been a market-beating investment. It may underperform the broader market in some of the biggest bull runs, but investors will be glad they own it when the market turns sour.

This is due in part to the kinds of businesses that Berkshire owns. The conglomerate owns businesses and stock investments that are durable and steady but not the flashy growth companies that tend to do well in an exciting market rally.

3. Boston Omaha

Often referred to as a mini Berkshire Hathaway, Boston Omaha (BOC -1.30%) does have some of the same characteristics that make Berkshire an attractive investment. To be clear, there is no comparison between the track records of these two businesses. Berkshire has been a winning investment for decades, and Boston Omaha is still in the early stages of growing into the conglomerate it wants to be over the long term.

That said, the basic idea is the same. Boston Omaha invests in stable, durable industries as the basis of its businesses. Most of its revenue comes from billboards, broadband internet, and insurance. There's also a newer, smaller asset management business that is just getting off the ground.

In this sense, Boston Omaha as an investment shouldn't have much to do with the overall stock market's behavior, and the business's success should be independent of market sentiment. While it did not match Berkshire's performance over the past two years, it did outperform the market in 2022, which could suggest it has some of the same resilient qualities as its larger conglomerate peer.