In the past, with most electrical gremlins, first on the list is to disconnect, inspect, and reconnect ALL of the in line connectors from the battery to the problem. Once fixed with a check over, continue riding.
Not sure how y'all like WD-40 or di-electric grease.
Most all of the connections, especially light bulbs have a generous coating of Di-electric grease after inspection and super clean verification.
I have a friend that sprays everything with WD-40 if it moves or can move. I think he does shots of it once in a while.
I know he gets a spray down end of September every year.
WD-40. It's not just for breakfast.