You can't heat and cool at the same location at the same time. But you can heat and cool simultaneously two nearby points. So, part on the heated side will expand and part on the cooled side will contract.
OK, you could for instance put a small metal marble in cold water and at the same time heat it with a radiative heat source like the sun. It is a 'point' that will be 'heated and cooled' at the same time, meaning there is a heat source a heat sink for the metal at the same time and location. But the metal will expand or contract only when the temperature of the metal changes. When the net temperature of the metal remains constant, it will not expand or contract.