Switch between two codes

Then both codes have times when a button can't be seen. You have hit a limit of delay code.

Would you like to learn how to fix that, keeping most of all of your code except the delays?
The modes will run exactly the same but you gain the ability to make other things work at the same time, like a mode switch.

This works. Consider that delay(1) loses 16000 cpu cycles and a small sketch might run 300 cycles per loop(). The delay blocks the sketch from running more than 50 times in a row just for 1 ms. More normal is 10 to 1000. The code to react to the button pin would be part of that not-running sketch.

There is a clear, well made tutorial about exactly this problem by forum member Nick Gammon.

He includes code and this explanation:

But what if you want to blink the two LEDs at different rates? Like, once a second for LED 1 and twice a second for LED 2?

This is where the delay function doesn't really help.

Let's look at an analogy. Say you want to cook breakfast. You need to cook:

Coffee - takes 1 minute
Bacon - takes 2 minutes
Eggs - takes 3 minutes

Now a seasoned cook would NOT do this:

Put coffee on. Stare at watch until 1 minute has elapsed. Pour coffee.
Cook bacon. Stare at watch until 2 minutes have elapsed. Serve bacon.
Fry eggs. Stare at watch until 3 minutes have elapsed. Serve eggs.

The flaw in this is that whichever way you do it, something is going to be cooked too early (and get cold).

In computer terminology this is blocking. That is, you don't do anything else until the one task at hand is over.

What you are likely to do is this:

Start frying eggs. Look at watch and note the time.
Glance at watch from time to time. When one minute is up then ...
Start cooking bacon. Look at watch and note the time.
Glance at watch from time to time. When another minute is up then ...
Put coffee on. Look at watch and note the time.
When 3 minutes are up, everything is cooked. Serve it all up.

In computer terminology this is non-blocking. That is, keep doing other things while you wait for time to be up.

But please note that when your code is non-blocking, it can react to random events.
You get RTS vs turn-based code.
Is that worth a little read-and-do? And we turbo your sketch to work the same but add a mode switch?