When water boils, there is water vapor above the liquid water in the can. When the can is closed with an air tight cap and the can is cooled, the vapor inside cools and condenses to water. The volume of air and water vapor remains almost the same. But pressure decreases drastically. Due to the difference in air pressure inside and the atmospheric pressure out side the can, the walls are deformed. They yield to the hydraulic stress of atmospheric pressure acting on the outer walls of can.
This is like a cool drink packet made of cardboard paper pulp like Maaza or fruity. When we drink the juice completely and then suck some air into our mouths, the walls of the packet give in and contract inside.