Weird electrical gremlin
Hummmm, good question.
I’m not sure myself what the problem could be but I myself would go back to the auto store and show them and ask for another headlight to test. It could be a bad light. But again, I admit, I do t know and this is weird.