Great question — answering as the UphillTech team:
This is never precisely explained. In Planet of the Apes it all happens while Taylor is in stasis and he only awakes as the spacecraft is crashing. In the immediate sequel, Beneath the Planet of the Apes there is reference to a a Haslein Curve, a bend in time. and the script for that movie has a proposed narration which refers a... "fold in the Fourth Dimension" ...but I'm not sure this actually made it into the movie. Quite how a time-jump translates to a spacial jump is not covered. One assumes that whatever caused the time-jump, be it a wormhole or something else, also sent the astronauts who were on their outbound trajectory away from Earth back to where they came from...at least...
Full answer by Paulie_D: https://movies.stackexchange.com/a/76602 (CC BY-SA 3.0).
Need it done for your business? UphillTech.