Gravitational capture

Gravitational capture occurs when one object enters a stable orbit around another (typically referring to natural orbits rather than orbit insertion of a spacecraft with an orbital maneuvers).

Asteroid capture turns a star-orbiting asteroid into an irregular moon if captured permanently, or a temporary satellite. Capture events explain how satellites can end up with retrograde orbits or rotation.

Planetary capture of a rogue planet by a star or other planet is also theoretically possible, but, none has yet been directly observed. Because the angle of encounter is somewhat random, such an event would likely leave the captured planet in an orbit outside the orbital plane of other planets in the solar system, possibly in a retrograde orbit.

Planetary capture has been proposed one mechanism that could explain the unusual orbit of the hypothesized Planet Nine in the Earth's solar system. (Planetary migration is a competing explanation.) Planetary capture (possibly planet swapping with neighboring stars) has been proposed as one explanation for why an unusually high fraction of hot Jupiter exoplanets orbits are misaligned with their stars and a few even in the retrograde direction.

Ejection
The opposite process, ejection from orbit, can occur through orbital instability or one or more encounters with another passing object (perturbations), eventually putting the object on a hyperbolic trajectory. Rogue planets can theoretically be formed in this way, and planets could lose their moons this way. Tidally detached exomoons have been proposed to explain some astronomical observations, but none have been observed. Severe stellar mass loss could also cause planets to escape orbit and go rogue.