Why does the LED turn on after the while loop becomes false?

This question is off topic, but to avoid making another thread I thought asking you would be much easier...

When you use the increment operator, is there a way to make it continuously increment until a certain value (ex. 8), then reset to 0 and repeat?

As this code only increments every time the button is pressed.

void loop(){

  if(digitalRead(3)== 0)
  {
    while(digitalRead(3) == 0);

    ledMode++; 
  
  }