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

BTW

Don’t take shortcuts, don’t place multiple lines of code after each other.
Follow this style:
if (walk == 1)
{
digitalWrite (motor1pin1, HIGH);
digitalWrite (motor1pin2, LOW);
}