Dry ice forms by compressing CO2 gas until it liquefies, then letting it expand, freezing into solid form.