Why does adding an 'if' effect my state machine?

Two aspects to your latest problem - if the button is floating, you may see a change between readings - do you have a pulldown resistor?

Also, you're printing a lot. That will block code execution, especially at 9600 baud and give the floating pin a little time to change state.