There’s a ton of current related interference. I tried running magfit on the flight a couple of times but each time it errored out saying “too many iterations”. I think that means it’s too bad for magfit to correct.
You may need to move the compass module or battery/ESC wires, or look into some shielding. From what I see this is going to require a physical fix before you can tune it in software.
As for why it works sometimes and not others: That might be a case of sometimes it works “good enough” that you don’t see the issue.
I just noticed one log showed two compasses, but the other only showed one. If you have an internal and external compass on your controller then I’m going to suggest to just use the external because often (not always) the external is better. In this case you may need to tinker with that.