Smaller banks are usually pressured into offering higher interest rates to compete with larger banks. Holding cash gives you exactly 0%, and short term maturity bonds pre-2022 basically gave you roughly 0%. So, as a small bank how do you entice your customers to keep money in your bank? If the large banks are offering say 0.5%, you're probably pressured into offering ~1%. And how do you afford to do that? By buying longer term bonds.
OK, now comes 2022, inflation is high and you think the Fed will increase rates. Now your bonds have already dropped in price due to the anticipated rate hikes. The billion dollar question now is whether you believe the Fed's "it's fine, don't worry we can get inflation under control", and keep your bonds, or whether you believe aggressive rate hikes are coming? It's easy to ridicule in hindsight, but as the saying goes hindsight is 20-20.