The hub is the center of the wheel and connects the wheel to the bike. It must allow the wheel to rotate freely so that the bike can move. It is like a solid axle that is attached to the bike and has bearings that connect it to an outer shell into which the spokes of the wheel are fixed.
The flange is a specific part of the hub shell. It is the part to which the wheel spokes are attached. It therefore has a number of spoke holes. Some hubs now have a flangeless design and have spokes that run through the hub shell. This gives a cleaner appearance and reduces the rotating mass.