My First Arduino Project

Your button input when not pressed is causing a 'floating input' condition on the input pin and returning random value. Either wire a pull-down resistor from the pin to ground (10K ohms) will fix the problem, or a simpler method is to wire your button from ground to the input pin and then do a pinMode(2,INPUT_PULLUP); command in your setup function. Then reading a low means the button is pressed and reading a high means the button is not being pressed.