In the US, banks do invest in the stock market sometimes - just like they lend money to people sometimes. However, they can only invest or lend some of their money, and they have to be very careful with the risk profiles of their investments and loans. They have to keep a certain amount of money as cash; thus, in Europe's case, the ECB.
This article for example talks about this:
Banks differ from other financial institutions in part because of strict regulations that control their activities. Although these regulations don't forbid banks from investing in stock, they do limit how much banks can invest. The purpose of these regulations is to ensure that banks don't risk -- and lose -- too much in the stock market, which could hurt their ability to remain in business and repay depositors.
Federal banking regulations limit how much banks can invest in stock, how much cash they must keep on hand to cover customer withdrawals, and even how much risk they can take on with their investments. As a result, banks usually avoid stocks that are high-risk or highly volatile. Instead banks use stocks to round out, or diversify, their sources of income.
Some European central banks even invest in stocks. See this article about this practice in 2018:
Switzerland’s bank, by contrast, seems to be acting more like an aggressive individual investor: it has been buying stocks because that is where money is to be made. Unbeknownst to many American investors, the Swiss National Bank is a significant shareholder in well-known American firms like Amazon, Apple, Facebook and Microsoft. (Overall, a little more than a fourth of the U.S. stock market is owned by non-U.S. shareholders, but the Swiss bank’s high concentration is unusual.)
All that said, the entire point of negative interest rates is to encourage banks to not hold on to too much cash; as banks can and do keep more than they're required to if they think it's the best strategy at the moment (if they are worried about a downturn, say, or just don't have any great opportunities at the moment). See for example this article:
The theory is that commercial banks will be dissuaded from maintaining large balances with the central bank and will instead lend money to businesses and consumers who will, in turn, spend the money. The increase in lending and spending is likely to boost economic activity, leading to growth and inflation. In this way, negative interest rate policy is considered by many to simply be an extension of traditional monetary policy.