I’ve dealt with Mach3 threading problems like this before. The version does matter: the Mach3 documentation specifically mentions a major change to the threading code around R3.042.032, and that version was intended for a single-index setup. So I’d first check exactly which Mach3 build you are running.
That said, if the first 2–3 passes are correct and then the tool gradually moves off the thread, I would check the spindle index signal, index sensor, debounce setting, and spindle RPM stability before changing versions. Mach3 has to see a consistent index pulse on every revolution to synchronize the Z movement correctly.