How does a=2 twice in this code sample?
Think carefully about the flow.

Your innermost While loop runs through b = 1, 2, each time it hits.

It does this for EACH value of a in the outermost loop.

So when a == 2, we progress inward and run through that loop twice. a == 2 both times.