The way foam mattresses work is weight deformation. If your butt is heavier than your head, it sinks in more.
I’ve never seen any evidence to suggest this was good for spinal alignment. If you’re a side sleeper, it can also be bad for your shoulders if it doesn’t sink in enough.