Actually water inside the can turns to gas when heated filling the can with water vapor. When the can is stoppered and cooled the water vapor turns into a liquid creating a partial vacuum which can not push back against pressure of the atmosphere. Thus atmospheric pressure crushes the can.
Did this at school oh so many years ago, but the difference : we then heated the crushed can and expanded it again : obviously the consequences of Health & Safety...