If there is competition between banks, then each bank tries to be better than the other banks. In order to be better than other banks, a bank must seize opportunities which other banks have missed. In order to be better than other banks, a bank must be different from other banks. If there is competition between banks, every bank will be different, and will have different policies and different loan standards. Competition results in diversity. Thus lack of diversity is caused by lack of competition, which is usually caused by overregulation.
So if all banks are refusing to make loans to certain neighborhoods or to certain racuak or ethnic groups, then that means one of three things. Either those loans are obviously a bad investment, there is insufficient competition, or the government regulators are forbidding banks from making those loans.
Within any neighborhood, or within any racial or ethnic group, there are usually some people who are a good investment and some people who are a bad investment. Even if some neighborhoods or racial or ethnic groups are a worse investment than other neighborhoods or racial or ethnic groups,
For example, in San Fransisco in the 1800s, the banks refused to lend to italian-americans. So some italian-americans started their own bank, which specialized in lending to italian-americans. This bank was very successful, and eventually grew into Bank of America. So when african-americans complain that they cannot get bank loans, we should ask why no one starts a bank which specializes in lending to african-americans. Probably the answer is that the government refuses to grant a banking license to any such bank. So if the banks are discriminating against african-americans, it is the government's fault, not the banks' fault.