How do i get my if to repeat untill another if value is entered.

I strongly suspect that you are faced with a huge re-write of your program to remove all the delay()s as they are almost certainly the reason why your buttons don't react immediately - you have to hold the button until the current sequence ends and the code gets back to line 9.

The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

However, it should not be necessary to write your code in such a long-winded fashion if you learn about using arrays to hold the pin numbers for the LEDs.

I also think you will need to separate out the detection of the switches from the code that causes the flashes. In other words when a switch is pressed it causes a variable to take a value. If that value changes then a different sequence should start. And to keep the code short, when a new sequence is selected by a switch there will need to be some initial setting of values to make the sequence work. With suitable values the real work of flashing the LEDs in the first sequence could be dealt with something like these few lines

       for (byte n = 0; n < 3; n++) {
            digitalWrite(ledPin[n + ledPinOffset], ledState);
        }

My idea with the variable ledPinOffset is to be able to select the first three LEDs or the subsequent three.

You will need a variable to count the flashes and change the value of ledPinOffset at the appropriate time.

Finally (for now) it is probably not a good idea to expect an analog input to give an exact value such as 538. A test such as

if (val >= 538)  {

would be much safer. (of course I may have the logic wrong, but you should get the idea)

...R