Saddles are popped on to their rails under some pressure in the factory. Surprisingly, you can recreate that pressure when landing a jump badly, but not again five minutes later when you want to fix the thing.
You may be able to force the rails back in by finding the end that has least insert, putting the other end in place and using a lever (a screwdriver, branch, etc.) to apply pressure to the rail so that it can be pushed back into place.
If this won’t work, consider cutting the sockets for the rail just enough so that the rail slips back in, and then zip tying it in place. The trick here is to prevent fore-aft movement, as this will allow the rail to slip out again.
If you lost or broke the top part of the saddle, use an inner tube to lash a stick across the two rear parts of the rail (perpendicular to the top tube). Now lash another stick from this stick to the front of the rail. Inner tube will slip very little against the metal rails, and will provide some padding. A hydration pack or clothing on the sticks will provide some comfort.
If all of this fails, remove the seat post and pad the area of the frame where your rear end will rest. Be careful not to slip back on to the rear wheel.