It takes time for the energy of a system to change. It might help to get an intuitive feeling for what that energy really is; it's the kinetic energy of the molecules contained in sand. When rays of sun light hit the sand, some of the energy contained in the light is transferred into the sand, causing these sand molecules to "jiggle" and to feel hot to the touch. When the sun sets and no more rays of sunlight are available to keep the sand molecules "jiggling", the jiggling slows down over time, for a variety of reasons; some of that energy in the sand is transferred into the ground, into the air, etc...