Why are you using an int from an analog input instead of a digitalRead?
wire your button from the desired pin to gtound. set the pin to INPUT_PULLUP mode and test for
if (digitalRead (pin) == LOW) when pressed.
Get rid of the greater than logic and smooth that logic out. When the button isn't pressed the AI may be floating and noisy, triggering your state logic randomly.