How can I prevent beer cans from exploding?
The best way is to keep the beer cans out of direct sunlight and store them in a cool environment as best as possible.
Normally cans of beer should not explode and your situation as mentioned in the comments is an isolated event. Your can may have been defective in some way or became damaged during transport.
I have had cans explode on me by accidentally dropping them in a hard surface floor, so I would try to avoid that too.
Some believe that overcarbonation is also another issue apparently, especially with a few craft beers in cans.
Beer is the age-old summer favorite drink for barbecues, bars, and trips to the beach. But recent summers have seen a fair share of critical injuries caused by exploding beer bottles and cans. A New York City bartender at The Frying Pan restaurant recently filed a negligence lawsuit against brewing giant Constellation Brands Inc., and others after he was left permanently blinded when an unopened Corona bottle exploded. This incident comes on the heels of several other beer product-related injuries, including recent reports of craft beer cans exploding. Although these may seem like straightforward product liability cases, the complexity of the beer fermentation process and the storage precautions consumers are expected to take beg the question of who is liable for these safety hazards.
According to Draft Magazine, beer bottles tend to explode as a result of [**overcarbonation. If a beer is bottled before the fermentation process is complete, the resulting carbon dioxide has the potential to build up enough pressure to break glass and cause serious injuries. - Exploding Beer Bottles And Cans: A New Wave Of Product Liability Litigation
Generally speaking though such cases are extremely rare. And again, in normal air conditioned home cans should not explode. If you do not have air conditioning, use your refrigerator, at least for the craft beers, just to be on the safe side.