Basically there's a lot of money out there floating around, especially after we pumped with COVID. It has to go somewhere, and mostly ends up in asset appreciation (stocks and real estate).
You're right though that the reality of shortages via a missing 20% supply of oil is a problem, and with all this cash floating around will eventually show itself as stagflation. That said, oil's pass-through to the broad indexes is historically weaker than it feels, so the pain will likely hit consumer purchasing power and corporate margins before it really shows up in the headline stock numbers.
Stocks (naturally) price in inflation before inflation becomes headlines everywhere. People uncertain about the dollar trying to shelter their wealth from inflation will move to stocks to shield themselves.
The best strategy then would be to know when the retirement fund money stops doing this due to age pyramid collapse i would assume.
When a buyer buys a stock, they are not giving money to the business.
Als, businesses get removed from the SP500 all the time:
https://www.bankrate.com/investing/s-p-500-stocks-list-of-ad...
They generally have to perform (profit, profit margin, revenue growth, market share growth, political influence growth, etc), and the higher the performance, the more their shares are worth (obviously).