Luck + based off the catch rate as they had low health and you used pokeballs that A. fit the situation or B. were top of the line pokeballs.
It may just as well have been the the same formulas and you would have spent forever which is why you got kind of lucky.
The odds were in your favor.