the bot knows because the decision was preprogrammed into the microcontroller
They give the competitors a map of the correct gates like 2 days before the competition.
I've seen many ways it has been solved . . .
Some people use timers of when to choose directions.
Some use encoders to measure distance before choosing the next direction.
And various camera algorithms that in various ways detect the split in the line. I'll be using a camera this year, but my algorithm is secret