I does sound like you’ve got a faulty door switch. Not an unusual thing. I’ve figured out which door switch is the faulty one by opening each door one by one and pressing the switch button near the latch mechanism manually. A bad switch will usually be obvious; it won’t turn the dome light and door ajar light on and off like it should in a consistent fashion. Coincidentally I had to do that diagnosis just yesterday on my Corolla. Driver’s door as expected. It’s the door used most often. I was able to jiggle it this way and that and get it to start working again.
The relationship to braking , when you brake with the car moving, the nose of the car moves down and the tail end moves up, so perhaps that motion is the reason. Or does this happen even when the car is stopped and neutral? If it happens then, it might not be a door switch and instead be some kind of grounding problem.