If the banks weren’t on the fractional reserve system this would not be a problem.
If all deposits were required to be backed up by real funds actually in the bank, this would not be a problem.
Then they would just be vaults. The purpose of a bank is to hold your money AND to lend it out to qualified borrowers to earn interest. At least, that's the basic premise. It only becomes a problem if, as in the classic movie, everyone wants to withdraw all their cash at one time.
As for the recent bank failures, a lot of that has to do with just poor investment/oversight/management; e.g. they put depositors cash into treasuries (which they are now required to do by law) but they bought long term treasuries at low rates and now the yields on those T-Bills are much higher, so if they had to liquidate the old low-yield bonds they have to dump them at a 10%-15% discount to book value. Proper money management they would have hedged the interest rate, or, kept it in short term treasuries so they could roll them over. But ultimately they need to lend it out at 2.5%-3% above Treasuries sometimes more - so people can buy homes or real estate for their businesses.
Of course, so much regulation all of this is mostly theory. Banks will 'originate' a loan but then sell it to investment groups so they aren't at risk and earn a small slice on the life of the loan. Who knows what else they do, what they are supposed to do, and how they do it? The bigger the bank and the broader their investment the more scams they can pull. The biggest Wall Street banks can make a sweetheart deal for a AAA+ credit large enterprise and still find a way to skim 16 different fees.