It is important to keep power and its return physically together to avoid magnetic loops. That is why using cable with the power and return in one sheath makes a lot of sense. It is also a good reason not to use the hull as a power return. The size of the magnet created is the area between the power and return wires times the current being drawn.
I am surprised that the nav lights cause this deviation, because the current is low, just a couple of amps. I had a Cherokee once that had a poorly wired backup radio: when it was turned on, the compass turned about 20 degrees. I never was able to fix it because I could not mess with the wiring harnesses, just allowed for it while navigating.
There is no easy fix. Make sure that the nav lights are not grounded to the hull, and that the return wires follow the power back to the ground bus in the panel.
1975 32' Flybridge Sedan, twin Perkins 6-354 diesels, 1:1.53 velvetdrives, 16 X 19 props. Merritt Island, Florida