Here are the most likely problems in no certain order:
Some
electrical device (inverter,
alternator,
battery charger, fridge, etc.) is interfering with the flux gate compass. When the interfering device turns on or off this moves the magnetic field and the flux gate changes accordingly. This can also happen to a regular card compass. We had a
boat that when
bilge blower turned on the compass rotated 10 degrees. Try turning off everything except the AP and
instruments.
The
wiring from the flux gate compass to the computer is corroded or loose.
The flux gate compass is sticky. Sometimes they get that way after many years.
The calibration data in the AP computer is getting
lost after
power is turned off. Depending on age the nonvolatile memory may be going bad.
When you "calibrated" did you do the long 360 degree turns to accomplish the auto calibration? It's not enough just to enter the compass offset. You have to do the lazy 360 turns as described in the AP manual. If the
engine alternator wires to the
battery run near the flux gate that can prevent a good calibration.