Timer relay with three buttons

I use this code. But when I am uploading it the relay starts switching even the button is not pressed. Stays on for a while and then turns off. The button is doing nothing if i push it.

And how could I avoid the loop function. I just want to run trough the programm only if i press the button.

const int buttonPin = 2;
const int ledPin =  13;
int buttonState = 0;
 
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
 
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}