How it works
Summer isn't when Earth is closest to the Sun. Earth is actually closest in early January.
Seasons happen because Earth is tilted by about 23.4°. For half the year, the Northern Hemisphere leans towards the Sun: sunlight hits it more directly and days are longer, so it's summer there.
Six months later it leans away and has winter, while the Southern Hemisphere gets summer.