It certainly is possible for a run on the bank to drive it into insolvency. And yes, if the bank makes some bad loans, it can magnify the problem.
Generally, this does not happen, though. Remember that banks usually have lots of customers, and people are depositing money and making mortgage payments every day, so there is usually enough on-hand to cover average banking withdrawl activity, regardless of any bad loans they have outstanding.
Banks have lots of historical data to know what the average withdrawl demands are for a given day. They also have risk models to predict the likelihood of their loans going into default. A bank will generally use this information to strike a healthy balance between profit-making activity (e.g. issuing loans), and satisfying its account holders.
In the event of a major withdrawl demand, there are some protections in place to guard against insolvency.
There are regulations that specify a Reserve Requirement. The bank must keep a certain amount of money on hand, so they can't take huge risks by loaning out too much money all at once. Regulators can tweak this requirement over time to reflect the current economic situation.
If a bank does run into trouble, it can take out a short-term loan. Either from another bank, or from the central bank (e.g. the US Federal Reserve). Banks don't want to pay interest on loans any more than you do, so if they are regularly borrowing money, they will adjust thier cash reserves accordingly.
If all else fails and the bank can't meet its obligations (e.g. the Fed loan fell through), the bank has an insurance policy to make sure the account holders get paid. In the US, this is what the FDIC is for. Worst case, the bank goes under, but your money is safe.
These protections have worked pretty well for many decades. However, during the recent financial crisis, all three of these protections were under heavy strain. So, one of the things banking regulators did was to put the major banks through stress tests to make sure they could handle several bad financial events without collapsing. These tests showed that some banks didn't have enough money in reserve. (Not long after, banks started to increase fees and credit card rates to raise this additional capital.)
Keep in mind that if banks were unable to use the deposited money (loan it out, invest it, etc), the current financial landscape would change considerably.
- Free checking accounts would go away. Why would a bank want to assume the risk of watching your money if they couldn't get something out of it?
- Interest bearing deposits like Savings Accounts and CDs would go away. The bank is able to pay you interest because they are doing stuff with that money which yelds a profit for them (of which you get a cut in the form of interest).