Ok, I googled that funky MegaRange 14-34 (first picture) and it appears to be a 7-speed threaded freewheel. The second example is a bit harder to make out but it appears to be a modern cassette+freehub design, not sure how many sprockets. The two designs are incompatible and use different hub styles.
The freewheel design includes both the sprockets and freewheel (the mechanism which lets you coast) as one piece, which screws onto the hub body. This is an older design and is limited to a lower number of gears, typically 7 or less. I'm not sure of any clear advantage, other than it's easier to replace the freewheel in this design. It's been a long time since I had one of these.
Most modern hubs use the second freehub design, where the hub includes the freewheel mechanism. The sprockets come separately as "cassettes" and can be slid onto the freehub; a locking ring (black in the picture) holds the cassette in place. Cassettes make it easier to change out a worn sprocket set, or to switch between different sets for different conditions (e.g. one for flat terrain, another for climbing). Because the cassette widths are standard, you can often upgrade to more sprockets without changing the hub (although you still need to upgrade the shifters). The tradeoff is that to replace the freewheel you'll end up replacing the entire hub.
For more details (with pictures), check out Sheldon Brown's site.