Days are longest in the summer for the northern hemisphere due to tilt of the Earth's axis allowing for more sunlight to be projected onto surface. Longest day of the year is at the summer solstice For opposite reasons, days are short and nights long in the winter. The seasons are caused by the angle the sun's rays make with the ground. Higher Sun angle means more luminosity per square meter. Low Sun angle produces fewer rays per square meter.
More intensity means more heat and, therefore, higher temperatures.
Note that, due to the fact that our oceans store heat, the actual changes in mean Earth temperature are delayed by several weeks, i.e. the hottest days of summer are usually in late July, over a month from the summer solstice. For example, at the time the Pyramids were built the pole star was Vega. Typical we use synodic time, which means with respect to the Sun, in our everyday life. Astronomers often use sidereal time, which means time with respect to the stars, for their measurements. Since the Earth moves around the Sun once every 365 days, the Sun's apparent position in the sky changes from day to day.