But after nearly 20 years of D&D, it has become such a staple, astute players and GMs start to deconstruct the idea and wonder, like OP has done, why anyone would want to have a graveyard when it is the main source of undead.
I never thought about this before, but it seems genre theory can apply to tropes from the genres as well. Specifically, I mean the stages - primitive, classical, revisionist, parody.
Take our graveyard trope for example. The primitive stage of the trope would be the early literature and film in which undead came from graveyards or creepy dudes stole bodies from the graveyard for nefarious purposes (Frankenstein, Dracula, White Zombie, etc). Folklore held such myths, but seeing them brought to life through literature and film would be the primitive exploration/creation of the trope.
I think, for the most part, we don't get to experience the primitive stage in our gaming, as these things are only tropes we take to the game table after the trope has "matured" past that stage.
But classical graveyard, yeah, a lot of us have done that. Undead plaguing the town, mysterious noises from the graveyard on the hill at night, underground burrows beneath, all those trappings that are part and parcel to the trope.
Then there's the revisionist stage - such as we've been discussing here, cultures changing their death rituals due to the existence of undead, a populace, both PC and NPC well aware of the undead's existence, the types, how they are made, and steps to take to minimize the threat. And, too, DMs devious ways to get around the trope - the graveyard as sanctuary (because its hallowed ground), the undead menace having a non-graveyard source, the undead being raised as soldiers or guards by the town, etc. In film (TV) Buffy is a good example of a revisionist graveyard (and parody sometimes). It is numerous things in Sunnydale, information source (good guys doing the grave robbing, hunting for ancient scrolls and relics); the haunt of allies, informants, and villains; hang out spot; set piece for romantic, emotional or developmental character scenes; action setpiece; pretty much all things for all people.
The parody stage would be represented by things like RPGs featuring undead, good guy PCs, or interesting, tongue-in-cheek undead NPCs (the Hogwarts ghosts, for example; the Death Day party was pretty brilliant), undead or graveyard encounters as comic relief.
I agree with lin_fusan that the great thing about tropes is that they can be deconstructed, contextually, for a wealth of gaming opportunities, and that's why old tropes should never die.