In the first part of the ISR, it doesn't clear the interrupt flag if the value isn't 10.
So it exits and re-enters the ISR 10 times really fast.

Once it gets to 10, it toggles the pin and finally clears the flag, which all happens from a single interrupt.