OK, I was going off the symptom you first mentioned: “As in one motor moves forward and the other moves backward”. Is this still happening? Still just on the X axis? If so then it must be a wiring problem. Agree? If this is not the exact symptom and you are getting intermittent motion (but proper paired motor rotation) then yes let’s look at the other possibilities. I wanted you to avoid chasing down red herrings.
I will be happy to help out if you give me as much detail as possible. Professionally in debug situations I have probably “seen it all”, including all manner of strange intermittent power on issues including the “charge retention” you mentioned and it’s interaction with firmware. You don’t have a spindle motor running when this happens right?