If the switch is broken, the master controller for the locks thinks the door is still open and won't allow the car to lock. Another potential problem - moisture (usually from car wash) gets into drivers door and corrodes the connections to the controller. I've went through this more than once. Sometimes it just goes away.