Generally speaking, exploding wands are a Bad Thing. You lose a potentially useful wand, you may take damage from the magical explosion, and your inventory may also come to harm. The Guidebook says that in a truly desperate situation, you might decide to break your wand, but I'd say that you should only do that if you are doomed anyway and wish to take the monsters down with you. Some classes have a better chance of survival: Priests, Flame Mages, Ice Mages, Necromancers and Wizards take only 1/5 normal damage from magical explosions, and Healers and Knights take only 1/2 normal damage.
Two wands have nastier explosion effects than any others: cancellation and polymorph. Cancellation will cancel your entire inventory. Polymorph will polymorph you, with the usual potential for destroying your armour, and will then polymorph any of your weapons or armour which fell to the ground as a result of your polymorph.
The only 100% guaranteed way to protect your wands from exploding is to keep them in a bag. Reflection will protect them from exploding when you are hit by lightning, and maximum magical cancellation will greatly reduce, but not eliminate, the chance of a zap from a monster affecting your property.
Wands of healing and extra healing do not do any damage when they explode, and the hero and surrounding monsters are healed as if they had been zapped with the wand.
Wands of death, lightning, cold and magic missile simply explode with a pure release of magical energy. The amount of damage done to the hero and surrounding monsters is 4 times the number of charges for wands of magic missile, 8 x charges for wands of cold, and 16 x charges for wands of death and lightning. Whatever type of wand exploded, only magic resistance protects against the damage, and items are not affected.
Wands of fire and fireball produce an explosion of fire, doing 4 x charges points of fire damage for a wand of fireball and 8 x charges points of fire damage for a wand of fire. Objects on the hero's square and surrounding squares may also burn or boil, and slime will be burned away.
All other wands have a more complicated effect. First they explode with a release of magical energy. The maximum damage done is the roll of (1 + charges) 6-sided dice for wands of striking, 8 x charges for wands of create horde, and 4 x charges for other wands. The actual damage done is a random number from 1 to the maximum damage. As before, whatever type of wand exploded, only magic resistance protects against the damage.
Assuming that you survived that, there's more. All monsters and items on the squares surrounding the hero are affected as if they had been zapped with the wand (except that an exploding wand of make invisible affects only monsters and not items). A wand of create monster or create horde creates large numbers of monsters around you, and a wand of digging creates pits and holes. Finally, you suffer the effects of zapping yourself with the wand, and any items on your square are also effectively zapped. A wand of teleportation may create a teleport trap, and a wand of light will light up the room.