This is how QE is supposed to work:
The fed buys government debt from banks. This lowers the long term interest rates and businesses and consumers borrow more, which is good for the economy.
But what if the banks instead of lending out money put most of their money in the stock market? They know that somewhat later the money will get to the general population. And some of the general population make a good living. So good in fact that they save a lot of money in index funds, and in particular when the interes rates are low. The banks already know in advance that this will drive up the stock market. Since they can buy the stocks before the money has reached the general population they can buy the stocks at a lower price.
As a more detailed example assume the investment bank G. Gecko own 1e6 10 years treasury bonds at USD 1000 per bond. The bonds have a coupon rate of 10 USD, resulting in a yearly return of 20 USD = 2%. Now the Fed starts buying up 10 year treasury bonds and the price of these rises to 2000 USD. Now the return rate of these bonds are only 1%. This is not enough so G. Gecko sells it bonds. Now it has doubled its money but it need to invest these somewhere. So it buys Apple stocks. Another bank also sell treasury bonds but use the new money to lend out. This improves the economy and some of the general population gets more money. Some of this they use to buy Apple stocks. However this drives up the price of the Apple stock. Let us say it doubles. Now G. Gecko have turned their initial 1e9 USD into 4e9 USD. Apple does not benefit directly from the rise in its stock price? The general population seem to benefit from the money trickling down from the other bank but the big winner here seems to be G. Gecko.