As others have pointed out, there are lots of reasons. Some of it is just that Apple was the first to change the game and that gave them a big head start in market share. And they did it again in the world of smartphones with the iPhone (although their phone market is now slipping).
A huge reason is the "ecosystem" that's grown up around the iPod/iPhone. Nearly every car maker now offers an iPod/iPhone interface in their most or all of their cars. You can use the dock connector and control your Apple device from the factory stereo. And most of us own cars. So right there Apple has a giant advantage.
And now you can remotely unlock, and even start your car from your iPhone. I'm not aware of any car maker with a full featured "dock" to any non-Apple device. Although, given that Microsoft is behind the Sync/MyTouch system, perhaps we'll see a Zune and/or Windows Phone 7 dock someday.
And in home audio, nearly every major manufacture offers some form of iPod dock or iPod interface for their receivers and sound systems. Just like in the car, you can run your iPod/iPhone from the remote for your home A/V system which is a big plus--and something you can't directly do with any other brand of player. There are even dozens of "clock radio" docks for iPods/iPhones. What other company has this kind of third party support?
Apple also manages to keep updating their products on an aggressive development cycle that keep people buying new ones. They make the new generation even more desirable than the last and keep most of their customers from buying non-Apple products even when their Apple stuff dies.
Are iPods/iPhones the best in their class? In some ways they sometimes are or have been. But they also have lots of negatives. Apple has done an amazing job of getting their customers to focus on all the things they do well and much less on the closed architecture, obnoxious practices, unloved iTunes, bad antennas, overloaded wireless networks, functionality problems, etc.
And, as others have said, Apple cranks out sexy, desirable products that make people "ooh and ah" when they first see, touch and use them. Ever been in an Apple Store? They're always jammed with people leaving their drool all over whatever they're fondling.
As most know "Sex Sells", and in the case of Apple, you just have to add one letter: "Sexy Sells"