Even though the bank often relied on the income from the mortgages to pay CD holders, they were required by law in many states to put a ceiling on the interest they could charge. In essence, the money they were lending to homebuyers was coming from savings products held within the bank, such as the CDs, which paid at much higher rates than the return from the mortgage.
That caused distinct periods during which even banks were practicing negative carry, although maybe less purposefully than someone doing it with a bond market or forex transaction. Over time, of course, the CD rates dropped, and the mortgage loans became more profitable, a universal happy ending for the best of all negative carry strategies.