It all depends on how you coded everything.
When you go back to a layout, the code is executed again from the "On start of layout event".
Nevertheless, if you used global variables and/or global objects, those are still in memory, and then you have to "reset" them from the gameover layout, when you click on restart.
For example, a global HiScore variable needs to be set to 0 (or else the game will start again with the current score).
Same goes for global objects, you need to set them to their original start position/content/instance variables values, etc...