These phenomena are called phase transitions, and are studied in the field of thermodynamics