Comets have highly elliptical orbits.
When at perihelion or closest approach to the Sun, they are typically about the same distance from the Sun as the Earth is. When at aphelion or farthest distance from the Sun, they can be well outside the orbit of Pluto. In 1950 Jan Oort was analyzing the comets whose orbits had been determined. At these large distances from the Sun, these comets are only loosely gravitationally bound to the Sun. A slight gravitational nudge, from a star passing within a couple of light years or so perhaps, is enough to change their orbits dramatically.