This is basic probability.

Think of flipping a coin

you have a 50, 50 chance of getting heads or tails.

However there is nothing to say you wont get 10000 heads before you see a tail.

Samething think applies with a random binary number.

So I see nothing wrong with the code. Just remember that computers use pseudorandom numbers, so if you counted the number of times each one generated, and generated them 200000 times you might end up with something like 100019 of one and 99981 of the other, but if you do those as percentages, you basically have 49.9999% for one and 50.0001% for the other. So you will never truely get 50/50.

There is a way to make it so it will always switch, do one after the other, but then it wont be random