Warren Buffett's company Berkshire Hathaway (BRK.A -0.56%) (BRK.B -0.45%) has purchased many stocks over the years for its large equities portfolio, which is now valued at more than $337 billion.

But like any good investor, Buffett and the team at Berkshire are also not afraid to change their position or adjust their portfolio accordingly when they've made a mistake, which is why Berkshire has also sold many stocks.

Two of those, which were dumped after the onset of the pandemic, are the investment banking giant Goldman Sachs (GS 1.05%) and the large regional lender M&T Bank (MTB 0.76%). Both companies have had interesting journeys since the pandemic began. Did Buffett and Berkshire make a mistake in selling these two stocks? Let's take a look.

1. Goldman Sachs

When the pandemic hit, most banks were in a precarious position because even if they were much better prepared and run better than during the Great Recession, there wasn't much they could do if the economy simply shut down.

In the second quarter of 2020, Berkshire completely exited its position in Goldman Sachs. A few months later, shares of Goldman took off as the company benefited from market volatility that lifted Goldman's sales and trading revenue. At the same time, the ultra-low-interest rate environment and the excess liquidity in the economy also led to a flood of initial public offerings and special purpose acquisition companies (SPAC) that boosted investment banking revenues. This created a perfect storm in two businesses that Goldman has long dominated, and the firm generated a record $21.6 billion in profits in 2021.

While earnings have come down as market conditions have gotten more difficult, Goldman is still generating earnings similar to pre-pandemic, and many think the opportunities in investment banking and sales and trading have only gotten bigger for large players like Goldman.

Goldman's stock is up 55% since the beginning of 2020, so in that regard, Buffett and Berkshire did make a mistake. However, hindsight is 20/20, and I think Buffett and Berkshire wanted no part in a pure-play investment bank at the time because earnings can be difficult to forecast as is. Buffett and the team at Berkshire, which know banking very well, also may not have been such big fans of Goldman's foray into consumer banking at the time.

2. M&T Bank

The Buffalo-based regional lender M&T Bank was one of several large regional banks that Berkshire owned leading up to the pandemic. Right when the pandemic hit, Berkshire sold many of these regional bank stocks right away. More recently, Berkshire has moved to exit its last regional bank holding U.S. Bancorp (USB 1.13%).

I like a lot of these regional banks, but lenders with more of a local presence and less diversity from fee-generating businesses were likely ripe for selling during the pandemic. M&T, especially, made sense, given that the bank had a lot of hotel loans based in New York City. M&T, by and large, has been a very solid performer over its history but simply got caught in the wrong place at the wrong time during an event that very few could have predicted. 

M&T Bank's stock is down about 10% since the start of 2020. Furthermore, its valuation on a price-to-tangible book value basis has also fallen since the beginning of 2020. While I think the bank is poised to rebound after dealing with a lot of the disruption, I think Buffett and Berkshire made a perfectly reasonable decision to sell the stock when they did.