The issue of density vs city size is a common problem that transportation planners face. Most people think that the answer to highway congestion is lower densities. In reality, the larger the city, the larger the benefit of high densities, but less highway congestion is not one of the benefits. It's hard to wrap one's head around the issue in the general case, so a simplification helps.
Imagine a city that is circular in shape with constant population and job densities throughout. (This is an idealized example of sprawl.) The average commute trip length depends on the distance between home and job. For a given population, lower densities mean a larger diameter city, thus longer trip lengths. Longer trip lengths mean higher flows on each link of the transportation network. If the transportation network consists of roads and people travel in cars, that means a lot of cars going larger distances. These cars need to cross each others' paths, and there are also natural and man-made obstacles, resulting in bottlenecks. The longer the trip length, the more bottlenecks a driver must pass through, with higher levels of congestion at each bottleneck. Longer trip lengths make walking, bicycling and mass transit impractical.
On the other hand, imagine the same shape city with a larger population density. Now the diameter of the city is smaller, homes and jobs are closer together, trip lengths are shorter, and people must traverse fewer bottlenecks. As a side benefit, shorter trips mean that more trips can be made by walking and bicycling. A higher density also means that mass transit is more practical, because mass transit depends on masses of people wanting to use the same route. If a lot of people try to drive
cars, they will get in each others' way, but they don't need to drive to get to where they want to go if they can walk, bike or use mass transit.
Now imagine a dense circular city with all the jobs in the center of the circle. Now mass transit is extremely practical, because everyone travels to the city's core in the morning and back in the evening.
I have lived in small cities with moderate densities where travel was easy. I have also lived in much larger cities with about the same densities, and in these cities travel was very difficult. I have also traveled in San Francisco during rush hour and seen for myself the benefits of a dense urban core.
Note, however, that a city such as San Francisco with high densities and large size does not necessarily have low levels of highway congestion. It does not take very many cars to congest a highway network, and the advantage of high density is not to decrease highway congestion but to make travel easier by making trip lengths shorter.
A dense urban area needs to be planned that way from the beginning, with high capacity mass transit, walking and bicycling included. In particular, building high capacity mass transit as an afterthought is extremely expensive and disruptive.