I know organs are drastically squished and rearranged during pregnancy. How does the body just “know” where to put them all after giving birth? Does this ever get messed up? Example: could intestines get a little jumbled and never be in quite the right place again?
It has nothing to do with what the body “knows”. It’s just forces acting on objects. Think of submerging an object in water. The water doesn’t “know” where to go, it just gets displaced. When you remove the object, the water flows back into place.
As the fetus grows, it exerts force upon surrounding organs, pushing them out of the way. When that force is gone, things naturally return to (more or less) where they were before. It’s just physics.
If you take an advanced class on the human body, they will teach you that the inside structures of the body where most organs sit are divided up into different cavities or sections. Various organs sit in each of these cavities. But, each cavity has a lining or bag that separates it from other cavities. For instance, the heart sits in its own bag or lining in a cavity called the pericardial cavity. The bag it sits in is double walled. Imagine you have a balloon and you put your fist in the balloon until it is completely covered. You then have two layers of protection and two layers keeping the heart where it is supposed to be. So, the organs aren’t free floating and in danger of radically rearranging. It’s like you have a bunch of bags and one bag expands and presses against the others. When the bag that’s being pushy stops being pushy everything simply settles back into place.
Organs aren’t just floating about in there, there’s elastic connective tissue that holds them all in the correct positions.
The expanding uterus stretches this tissue and pushes them out of the way for a while, then they return to their previous positions once it empties out.
Of course, loss of elasticity and damage does sometimes occur so it’s not always good as new right afterwards.