Have you tried rebooring the autopilot (i.e turn off and then on again)?
W\e had it happent to us that the autopilot did a doughnut (360 deg turn) in the middle of the gulfstream under sail at 25 kts of wind - a bit scary.
Once I got the boat under control the autopilot indicated that we were on a course of 90 deg while I was heading due west towards Florida.
M resoruceful wife solved the problem by turning of the autopilot for 5 secs and then turned it on again. Worked a charm and never had problem since.
Also check for big pieces of metal oblects that you may have placed closed to the aitopilot compass unit...
Same experience, not once, but several times (along several years). Try to fix it and Raymarine changed the giro compass, but to no avail. I think that happens when the boat passes over some magnetic disturbance.
A reset of the autopilot and the chart plotter solved the problem, all the times.