Here's the idea. Because of the "loop", we are waiting for the first time when O1 and O2 differ. At that time, we have either "O1=tails and O2=heads" or "O1=heads and O2=tails". However, since O1 and O2 are obtained using the same coin, the two situations are equally likely. Hence the result.
Using this informal reasoning, you may however not understand why the simpler procedure doesn't work (indeed it doesn't). In order to show why it is important to use the first procedure (i.e. toss again the coin everytime), a more careful computation is necessary.
What does it mean that equals 0? It means that the coin was tossed a certain number of times, getting equal pairs of results every time, before finally we observe and . We decompose the probability according to the value of (it is the number of times we have to go back to step 1):
(the comma means "and") Then, we note that (indeed, it corresponds to matches before the first difference, and O2 is heads). A short computation then gives you .