While you sleep!
Yes, after a training session and while you sleep your body recovers, repairs and adapts to your training load.
So remember how important RECOVERY time is after doing the physical work. That's why after Saturday long runs we all feel a little weary and enjoy an arvo nap - this is when our bodies are adapting and our endurance fitness is happening!