Hubs are black magic to a lot of people. I know that when I started screwing around with bikes back in the pennyfarthing days, when your hubs were also your cranks, I was intimidated by the whole setup. In truth, they're actually pretty simple beasts.
Witchcraft, I know, right? Let's pull it apart and see what we've got.
The hub shell is just a piece of aluminum (forged, then anodized and machined) that houses a few bearings and holds everything together. Apart from needing to be strong (the spokes anchor to it) and precise (the bearings get pressed into it, and the drive ring is in it), it's just a hunk of aluminum.
The cassette body holds the cassette, and the interplay between the cassette body and hub shell constitutes the transmission (next photo). When you coast, the pawls retract in against a spring, and the cassette body rolls against the drive ring of the hub shell. When you pedal, the springs pop the pawls out and engage them in the drive ring. That makes the bike go forward - the pawls are IMPORTANT little m-f'ers, as are their springs. No them, no go.
The pawls engage in the detents in the drive ring. This interaction is fairly important.
The axle and its end caps (sometimes both are removable, sometimes - as in this case - just one is) are how you attach the hub to the bike. The axle's other massively important job is to be the axis around which the bearings turn. A flexible axle is bad for wheel stiffness, and will cause premature bearing wear - it's generally bad for business.
Deconstructing this hub took some elaborate tools - two 5mm hexes. Most are similarly easy to pull apart, some even easier - you can pull a Powertap hub apart with your hands. A front hub is even simpler - it's just a hub shell, axle, bearings, and end caps.
Hub maintenance is simple, infrequent, and important. Once a year or so, depending on how much you ride and what conditions you ride in, pull things apart (take some phone pictures as you do it so you have an exact record of how everything goes back together), flush things out with WD-40 or some other super weak solvent (WD-40 works great - just use that), clean things off/out with a cotton rag and some Q-Tips and toothpicks, put some new lubricant in (check your hub maker's web site to see what to use - most are tolerant of a range of different stuff but some aren't), and close everything back up. If you're slow and deliberate, it might take a half hour to do both wheels.
Your service intervals will vary A LOT depending on your riding conditions. After the exceptionally muddy, nasty, and long Hampshire 100 this summer, I stripped and serviced a brand new set of hubs. Other times, I've gone a year between services and been totally fine.