Watch the video to the left. The can has a small amount of water in it. As we heat is up the H2O molecules in the can, begin to change from a liquid to a gas.
As the change, the bounce around and escape. This is seen as steam. Since the molecules have more energy they are hitting the sides of the walls more often. This means that even though there are less molecules in the can, they are still generating equal air pressure to the atmosphere.
However once we cool the can, the H2O molecules loose energy turning back into a liquid. This means there are less collisions inside the can, meaning the outside pressure is greater, causing the can to implode.
The opposite is true where, if we increase the air pressure inside the can, it will explode. This is because there is more pressure inside the can than outside pushing on the can.