That isn't always what happens. Objects will usually get closer to the temperature of their surroundings ("the environment"). If something is hotter than the environment, like hot food or hot coffee, the object will cool down over some time interval to match the temperature of the environment. If something is cooler than the environment, energy moves from the environment INTO the object until the object's temperature matches the environment. like ice melting or cold water getting warmer. This process of an object's temperature getting closer to the environment's temperature is a result of the Second Law of Thermodynamics.