The difference here is that the lender is looking at their entire tranche of loans and how those loans as a group make money. If they make all loans at zero percent, the money has to come from somewhere else. In the real world of finance they may give 0% to 5-20% of their customers. The other customers, with worse credit, pay higher rates. The government tells lenders they have to keep their overall risk at X%. (It changes so that is why X rather than a fixed number). The bank can literally loan out more money by giving excellent credit customers a 0% loan. Many of those customers would pay cash otherwise and those numbers don't offset the riskier deals.
So yes, the bank is going to lose money on some deals, but that helps them make even more money on other deals. The concept is similar to loss- leaders in retail. The grocery store can afford to sell some things at less than cost to get customers in the door. They will make up the difference on other products.