To answer the first part of the question, when a substance melts, energy is being added. Melting occurs when a solid turns into a liquid, and this process requires energy to break the bonds holding the molecules tightly together in the solid state. As heat is added, the temperature of the solid rises until it reaches the melting point, at which point the solid begins to change into a liquid. This energy input is crucial for overcoming the intermolecular forces that keep the molecules in the solid state.
Now, for the second part of the question, when a substance freezes, energy is being removed. Freezing is the process where a liquid turns into a solid. To achieve this transformation, the liquid must lose energy in the form of heat. As the temperature of the liquid drops, the molecules lose kinetic energy and start moving more slowly. Eventually, they become arranged in a fixed, solid structure as they release energy to their surroundings. This removal of energy helps to strengthen the intermolecular forces that hold the molecules together in the solid state.