I can't figure out why the system will correctly check if the Master Switch and Door Sensor state when first booted. However, once passed these states, Ready State or Monitor Flap Open, , I can turn on and off the master switch and open the door, without it changing back to these initial states. Do I have to check inside each state for all inputs, which seems to defeat the purpose of the Switch Case statement.
Warning! I am not very good at following other people's code (sometimes I can't follow my own code!!!)
You seem to be confusing states with tests and actions, for example
Checking the master switch is not a state, it's an test. States are things that persist until something changes them, for example your dog flap being closed is a state. You then have to decide what actions have to happen while in the DOGFLAPCLOSED state by doing a test of anything that will move it to a different state. DOGFLAPOPENING is another state.
Inside the DOGFLAPCLOSED state you test for anything that would cause the flap to be opened. When that event happens you start the motors and change the state to DOGFLAPOPENING. In the DOGFLAPOPENING state you test for whatever would cause the flap to stop opening, then stop the flap and move to the next state.
You don't need priorSystemState = systemState; because in each state you test to see if you should move to the next state, and the next state will test for moving to the one after that. You have to work out for each state what needs to be checked and what action to take as a result.
States persist for a long time, 'long' being anything longer than it takes loop() to go round once up to as long as you like, years if necessary.
Tests take place in each state to see if an action should be taken and a move to a different state
Actions are the outputs, such as opening the flap. Once an action starts move to a different state.
++Karma; // For what you have done so far.
I've tried to clarify what I said a bit.