Does matter contract when it is heated?
No generally matter expands when heated.
Heating is an increase in energy, An increase in energy may break bonds causing a chemical reaction or a change in state.
Heating as an increase in energy more commonly cause an increase in temperature. Temperature is a measure of kinetic energy. The more the kinetic energy the more motion that there is in the matter
An increase in motion causes the molecules to move apart causing the matter to expand. This is true regardless if the matter is a solid, liquid or gas.
Changing from a solid to liquid is usually an increase in volume with only a few exceptions. Changing from a liquid to a gas is always an increase in volume. So adding heat that causes a phase change will usually result in an expansion of the matter.