It's called a critical capture. It happens and it's lucky. It's rare and is almost a guaranteed capture. You're lucky to get it. Source experience.
Critical Capture
A totally new mechanic of capture is the Critical Capture. This feature works like Critical Hits in battle where there is a slight chance that this feature occurs. Critical Capture will be noticed when you throw the Pokéball. It'll pause in mid-air and make a metal noise. When it hits the Pokémon, it will shake once and capture. This cuts two of the four random calculations out of the overal capture mechanic making it more likely to capture the Pokémon. However, it can still fail.
The calculation is done by a simple factor depending upon the amount of Pokémon species you have captured. It will run this calculation based upon the capture value calculated above and will then have another random number based upon the Pokémon you have in your pc.
http://bulbapedia.bulbagarden.net/wiki/Catch_rate
This explainers the chance of it happening.