Can a sketch write to EEPROM while it is running.?

Do you not think that you are trying to build something here on little or no foundations.
Making a robot learn a maze is not a trivial problem yet you ask the most trivial questions. Not that trivial questions are a problem they are an essential part of learning but by the time you get onto an advanced task you need to have all this stuff under your belt.

Why then in the code you sent me shall I store data after the if statement?

You don't have to that was just an illustration of what you might want to do and store stuff.

Why I have to put EEPROM.write (0,21)

You don't.

that if statement should go In the setup or in the loop

See what I mean, you don't have the basic grasp of how a program is laid out.

Is the above the 255 (0xFF) message?

Yes 255 is exactly the same as the bit pattern 0xff - the 0xff means the number ff in hex.

but now in an Arduino where I have never written anything in the EEPROM before:

Just because you have never written to it does not mean that there have been no writes to it. It could have been a factory test to see the EEPROM was OK in a finished arduino or anything.

You might be better putting a switch on the robot that indicates if you want to follow a path already in EEPROM or you want to forge a new path.

However I would do a whole lot more tutorials before you play about on your own.