DnD is fun because you get to make your own character and then adventure with them in a completely different world, and you can do whatever you want. Imagine a JRPG in which you can say anything and do anything and in which the world will constantly update itself based on your actions. DnD's a lot like a video game, just with all the restrictions removed, because your DM can and will make up new things on the fly to accommodate you. (Unless they suck at being a DM. Which actually isn't that uncommon. Uh oh.)
40K is fun because you get to completely customise and build your own army, and then go and beat up other people's armies with it. It's fun in the same way that building a team in Pokemon and then battling with it is. The execution's obviously a lot different (Your guys can move, nearly every unit is active at the same time, a lot more random chance, and so on), but the reason why it's enjoyable is pretty similar. Y'know, battle of minds, that sorta stuff. Oh, and painting stuff. Customising and painting your minis so they look exactly how you want is pretty important too.
Of course, both of them can suck horribly if you're playing with the wrong people, and they might just not be your thing in the first place. But I doubt anyone thinks that one game can please the whole world.