The Stock Market is not the Economy (and vice versa). While economic growth is driven by capital investment and consumer spending, stock markets move on investor expectations of future profits and interest rates, so stocks can go up when the economy is not doing well (and vice versa).
Example: After the 2020 COVID Stock Market Crash, the Stock Market recovered quickly despite a terrible economy with record unemployment.