People hook a lot of stuff, other than fish. I'm talking trees, rocks, logs etc and thats just a given. However there are ways to get your fly back on the water quicker than others.
Firstly, never jerk back the rod in an attempt to free your fly. Bending your rod sets the hook deeper and pretty much ensures your fly is lost forever. Plus, many rods are snapped this way either by point loading, or simply overloading: in a rod vs tree scenario, you can bet that gnarly old willow is gonna win.
Now I don't see the point of juggling and wriggling your line around for 5 whole minutes trying to free it only to lose your fly in the end anyway, so why not get it over with and back on the water quick?
The moment you hook into that obstruction resist the urge to pull back and 'strike', Instead point your rod directly at the snag, with no bend at all. Strip until the line is tight, then simply lean backwards, ensuring your rod remains straight, pointed directly down the line.
Much of the time you'll get your rig back as the hook hasn't been set into the obstruction. If it pulls free, check your knots / tippet and hook, and get back fishing.
If it breaks off simply retie: toy don't need an excuse to freshen up tippet and knots, and you'll be back and fishing in minutes.
Below is another handy technique from the boys at Gink & Gasoline