You have encountered the interlock system There's a fair amount of info about this on youtube but it's pertty general. The problem is each interlock system seems to e wired a bit differently, but they all work on the same principal.
If you've got a wheelchair door you'll encounter the same problem with it eventually.
I kept my interlock system in part because electricity is still magic to me. It also reminds me when I don't have a door closed. It's only happened once so far, but it's a good safety feature.