If you simulate it like that, it leads to a contradiction.
According to the problem, 2 coins are flipped, and we all agree that it leads to an event pool of {TT,TH,HT,HH}, where all 4 events are equally as likely.
In the simulation, however, you just ignore the “TT” situation, which leads to a total event pool of {HT,TH,HH}. Where all events are equally likely.
The way the problem was phrased was “2 coin flips happen, and I have a machine that tells me either if both are Tails or not, this time it turns out that there is at least 1 heads”. But the way you simulated it is “I will make coinflips until I have at least 1 heads”.