As in any section there are tension fibres above the neutral axis and compression fibres below the neutral axis. This then forms the couple to resist bending. A beam doesn't have to have flanges to have stiffness, however it is more efficient to have as much material as far from the neutral axis as possible to resist the moment and to make the best use of the materials.
If you bend a wide flange section about its weak axis, you are essentially bending two plates (the flanges) about their strong axis. The web just joins and braces the plates.