Turning the green light to yellow then red with a button. Then change it back to green with another button button

I don't know what I did wrong.

int buttonApin = 9;//one button to pin 9 on the Arduino
int buttonBpin = 8;//anther button to pin 8 on the Arduino
int red = 3;//Red Color to pin 3 on Arduino
int yellow = 4;//Yellow Color to pin 4 on Arduino
int green = 5;//Green Color to pin 5 on Arduino

void setup() {

pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
digitalWrite(green, HIGH);
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);

}

void loop() {
if (digitalRead(buttonApin) == HIGH){
delay(15); // software debounce
if (digitalRead(buttonApin) == HIGH) {
// if the switch is HIGH, ie. pushed down - change the lights!
changeLights();
}
}
else {
digitalWrite(green, HIGH);
digitalWrite(red, LOW);
digitalWrite(yellow, LOW);
}
}

void changeLights(){
// green off, yellow on for 3 seconds
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
digitalWrite(red, LOW);
delay(3000);
// this is to check if button is still pressed while delaying
for(long int i = 0; i < 600000; i++){
// if button is released
if (digitalRead(buttonApin) == LOW) {
return;
}
}

// turn off yellow, then turn red indefintily
digitalWrite(green, LOW);
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);

void loop() {
if (digitalRead(buttonBpin) == HIGH){
delay(15); // software debounce
if (digitalRead(buttonApin) == HIGH) {
// if the switch is HIGH, ie. pushed down - change the lights!
changeLights();
}
}
else {
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
digitalWrite(yellow, LOW);
}
}
void changeLights loop(){
//turn on green
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
for(long int i = 0; i < 600000; i++){
// if button is pressed
if (digitalRead(buttonBpin) == HIGH) {
return;
}
}
}

Usually, the point of the standard "Traffic Light Simulation" assignment is to test the student's ability to code without using the delay() statement (or similar blocking code) to achieve the time intervals. Protracted use of the delay() statement prevents the buttons being read in a timely manner.

Use the example "blink without delay" in the IDE to see how to code this more elegantly.

for(long int i = 0; i < 600000; i++){
// if button is pressed
if (digitalRead(buttonBpin) == HIGH) {
return;
}

Can you explain what is going on here, and the significance of the constant 600000?