How does hub diameter affect aerodynamics?
The key factor here is that the air at the hub is dirty - it's been disturbed by passing through the spokes and around the rim, so it's moving faster than the still air at the rim (slower relative to the bike), and it's turbulent. That makes improving aerodynamics both harder, and less important. The damage has already been done. Having a smooth outer surface is more important, since that's in cleaner air, and keeping it as small as possible since bladed spokes almost certainly have lower air resistance than the solid hub.

Mechanically a rim brake hub is a pair of flanges and a spacer. Since with bikes the goal is "everything as light as it can be", making that spacer smaller is a win. It needs to be big enough to enclose the axle, and strong enough to hold the flanges apart, but the job is not much more complex than that. So it can be very small and light.

With a disk brake the hub needs to be stronger since there's a torque between the disk rotor and the flanges. For the same reason it's rare to see a multi-part hub. That braking torque means a larger centre section allows thinner walls. Some mountain bikes also have thicker axles than road bikes, and obviously with those the minimum hub core diameter has to be larger to enclose the larger axle.

What definitely does improve the aerodynamics is making the hub much bigger, eliminating the spokes altogether. Which is why the UCI does not allow it :)