Given this is presumably powered from the RS5 board as there is no other source, I am hard pressed to see how the polarity gets reversed, it's an interesting question.
The funny thing is, it happened after the customer sent this to Lionel for repair, it came back not fixed, and the rear light didn't work right either after the "repair"! I have the locomotive working properly, this is the last item in the list.