A very common phrase in meteorology is the "Dog Days of August." That is used to imply that August is typically a very hot and oftentimes humid month. And that is a true statement for a good chunk of the country. So why exactly are both July and August so hot when the longest days occur in June? It's a phenomenon referred to as seasonal lag, or thermal lag. Essentially what that means is that while the longest days occur in June, the hottest days occur 1-2 months later. The reasoning behind the phenomenon is actually a simple scientific principal most of us learned back in basic science.
Both land and water take time to heat up. When the longest days occur in June and the solar insolation strikes earth's surface, it doesn't immediately result in warmer temperatures. It takes time for both land and water to see the sun's heat warm them up. There's essentially a lag that occurs. The same is true for the atmosphere. The sun's insolation doesn't immediately cause the atmosphere to heat up. It takes time for heat to warm things up. That's why the hotter temperatures occur in July and August as the graph above shows. The blue curve is the sun's insolation and red curve represents the actual temperatures.
That's also why going to the beach along the east coast of the United States may be more enjoyable in July, August and even September. The water is finally "heated up" by those months after the sun's insolation warmed it during May and June.