Logic gates and memory bits have very different fabrication processes (mostly because DRAM is optimized for a high density of big capacitors doing the storage).

You can put some memory on the logic wafer (SRAM) but it's area inefficient, which is wasteful on your expensive N2 wafer. So a dedicated DRAM process is vastly cheaper per bit, even at current elevated prices.