How to test an electrical switch to ensure the power is off
You did this while the switch was still in the box, didn't you. 

What you didn't know was that the box itself, and thus the metal mounting frame of the switch, us connected to safety ground, and bumping against that while touching hot created a short circuit.

One solution is to use an insulated probe, so it can't make that accidental second connection. Another is to use a non contact voltage sensor, which can pick up house current near its tip without needing any exposed metal; thats what I would recommend for most beginners.