Dry ice is actually frozen carbon dioxide. This is why is probably a good idea to only play with it in a well ventilated area.

It is formed amongst other things whenever you use a CO2 fire extinguisher (which holds liquid carbon dioxide) as some of the CO2 vapourises and it gets the energy to do that from the rest of the carbon dioxide which freezes. Often small quantities of dry ice are generated by discharging a fire extinguisher into a cloth bag.

To allow the use of solid carbon dioxide for cooling in chemistry without getting too cold you can dissolve it in methanol to form a slush. As long as there was still liquid in the slush the temperature does not drop below the freezing point of methanol so it can be used to cool things without freezing them solid (also with liquid contact the conduction of heat is good).