Help with my project for garage door arduino

Some better names for the variables would certainly help. Clearly, the pins are all involved in opening or closing the door, or testing whether the door is open or closed. So, adding door to the name doesn't help.

You are clearly not activating a door to open the door. You are activating a relay to open the door. So, for those pins that are used to open or close the door, using relay in the name makes more sense.

For the pins that have limit switches attached, I'd expect to see limit in the name. The A side names of relayA1, limitA1, relayA2, and limitA2 are much easier to understand, and are immediately obvious which direction they are.

You have not told us anything about how the switches are wired. For my money, connecting one leg to the digital pin and the other leg to ground, and turning on the internal pullup resistor is the easiest, most foolproof way to connect the switches.

Break the problem down into 4 parts. The A door is open and needs to move until it is closed. The A door is closed and needs to move until it is open. The B door is open and needs to move until it is closed. The B door is closed and needs to move until it is open.

Write a function to handle each part for the A door. The same function can then be called for the B door, if the input is a pair of pin numbers.

Call the appropriate functions from loop(), when the appropriate input is received (with the appropriate delay, if necessary).