Arduino registrating double clicks when pressing button

Hello! Here is the code i think is failuring:

while(digitalRead(button2)==0){ //waits for release
     if(digitalRead(button1)==1){  //if button is pressed
      seconds=seconds+1;           //increment
      if(seconds>60){              //if seconds is greater than 60 reset to 0
        seconds=0;
        lcd.setCursor(9,3);        //clear the second digit of the last number
        lcd.print(" ");
      }  
      lcd.setCursor(8,3);
      lcd.print(seconds);
     } 
      
      while(digitalRead(button1)==1){} //waits for press
   }

What can I do to help this?
Thank you in advance

You may think you pressed the button once, but the contacts inside it made contact several times due to contact-bounce.

Search this forum for "debouncing pushbutton" or similar.

while(digitalRead(button2)==0){ //waits for release
     if(digitalRead(button1)==1){  //if button is pressed
      seconds=seconds+1;           //increment
      if(seconds>60){              //if seconds is greater than 60 reset to 0
        seconds=0;
        lcd.setCursor(9,3);        //clear the second digit of the last number
        lcd.print(" ");
      }  
      lcd.setCursor(8,3);
      lcd.print(seconds);
     } 
      
      while(digitalRead(button1)==1){} //waits for press

In addition to MarkT’s comments, use HIGH or LOW, not 0 or 1!

Boolean values are 0 and 1, its how mathematics defines them. Arduino.h

defines HIGH and LOW as 1 and 0 for this reason. 0 meaning false is

hardwired into C. I don't think there's anything in the slightest bit wrong in using 0 and 1 for digitalRead and digitalWrite - 0 and 1 are inherently digital!

MarkT: I don't think there's anything in the slightest bit wrong in using 0 and 1 for digitalRead and digitalWrite - 0 and 1 are inherently digital!

You might not - but I do. There are lots of other constants in a typical programming environment which have the values 0 and 1. That doesn't mean that they are all interchangeable. Using the correct type helps ensure that the value you use is valid and appropriate. Relying on implicit casting and promotion and values that just happen to be equal is very poor practice.

Even using HIGH and LOW isn't the ideal answer. In the sort of simple program suitable to be run on an Arduino it's unlikely that your program will be complex enough for this to matter, but in the more general case it would be sensible to abstract these values further to indicate what the value/state represents rather than just the voltage levels.

Even using HIGH and LOW isn't the ideal answer.

At least, though, it's an acknowledgement that the programmer is aware that the function returns a state.

Frankly, I won't even look at code any more that uses 0 or 1 to compare the result of digitalRead() to. Use HIGH or LOW, or your own interpretation (PRESSED or RELEASED), or don't expect me to help.