That happened because Voyager 2 went over Neptune's north pole rather than an equatorial trajectory. Both to get a look at a giant planet's polar regions, and because that would get it closest to the moon Triton. So Voyager 2's trajectory got bent southward out of the ecliptic plane as a result of that.
While I'm here: why didn't Voyager 2 continue to slingshot to Pluto? The answer is that its trajectory would have had to bend by about 90° at Neptune, which would have required an apex closer to Neptune's center of mass than the planet's own radius - it would have crashed into the planet instead.
That happened because Voyager 2 went over Neptune's north pole rather than an equatorial trajectory. Both to get a look at a giant planet's polar regions, and because that would get it closest to the moon Triton. So Voyager 2's trajectory got bent southward out of the ecliptic plane as a result of that.
While I'm here: why didn't Voyager 2 continue to slingshot to Pluto? The answer is that its trajectory would have had to bend by about 90° at Neptune, which would have required an apex closer to Neptune's center of mass than the planet's own radius - it would have crashed into the planet instead.