while (buttonispressed) loop and its use

I ran into the following code for a sumo robot. Why is the while(BTN) part used? The code doesn't work without it.

#include <Wire.h>
void setup() {
//button
 pinMode(A2, INPUT);
  digitalWrite(A2, HIGH);
#define BTN !digitalRead(A2)
void loop() {
 Forward(0, 0); //Stop motors
  delay(100);
   if (BTN) { //Turn on program with button
    
 while(BTN){}
    while (!BTN) {
      //code for movement is written here, irrelevant
}
while(BTN){}
   }
}

Wow, that must win the terrible code of the day award!

But it's a crude/terrible way to have state change detection. Aka, just halt everything dead in it's tracks until the button si released again in order to do something only once for a button press.

My tip, drop that piece of code. And if you ever find such poorly formatted code again, see it as a clue as how bad it probably is...