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

@adrianoles
I think you will find the following tutorials helpful:

My take on reading and responding to buttons:

There is also blink without delay in the Arduino IDE.

I hope those help you.