Hi SleepTampa,
Your question goes to the heart of all mattress design and theory and would be something like asking “how does food work”
I’m also guessing that you aren’t looking for the technicalities that may take many years of study to really understand (the learning curve never ends).
In the broadest of terms though … and outside of the links that are included in the tutorial post that dn linked to … different types of foam and mattress components each have a different compression curve and compression modulus (how quickly a material gets firmer as you sink into it more deeply) and other properties which is how the alignment of each area of the body is controlled. There are also some mattresses that use zoning in more difficult circumstances.
There is more about some of the specific properties or specs of different foams that can make a difference in mattress design and theory in post #2 here and post #6 here may also help you visualize how a mattress affects alignment for different people but these only scratch the surface of a very complex subject.
For those who are more technically or mathematically inclined then there are some good books as well that go into this in much more complexity and detail including here and here but these are not easy reads and would be of more interest for those who are pursuing this in a more professional environment.
Overall … I would focus more on the “what and whether” of alignment that you can test for and “feel” in person than on the “how” behind it because studying the how can very easily lead to paralysis by analysis and information overload. The most effective approach is to use careful and objective testing with the help and guidance of someone with good knowledge and experience that already knows what you would otherwise have to spend a great deal of time learning.
It’s easier to find an expert that makes or sells mattresses than to become one
Phoenix