The shutdowns came in a two-year period when more and more customers switched to doing their banking online or through apps during the coronavirus pandemic. American banks closed a record number of retail branches during the pandemic as the industry consolidates and consumers embrace digital banking.