you could have a broken wire in the wire harness that goes from the body to the door. Opening and closing the door bends the wire harness back and forth every time you open the door.
I have seen it where the wire will break but sometimes it will touch and work and other times it won't.
Water intrusion isn't a problem normally. The window where water would hit it acts as a shield to keep the water on the other side of the wired connections. Unless the window was left open and got water inside the window and door panel. Condensation however, could cause door contacts to rust. If the holes in the bottom of the door have been plugged up keeping moisture in the door, that could lead to electrical problems.
The main thing is: can you make it happen so a shop or mechanic
can see when it is not working? If everything is working they might not find the problem because everything is working normally. They need to check it when it doesn't work.