Question: Twice in the books Daenerys has been in situations where it is reasonable to expect that she would have been burned to death, or at least seriously injured, yet has come out unharmed.

The first time was when she stepped into the funeral pyre of Khal Drogo, which resulted in her dragon eggs hatching. The second time is in *A Dance with Dragons*, when she is exposed to Drogon's fire.

In both instances, all that happens to her is her hair is burned away.

I can't be certain, but I believe there may have been references in the first book to her touching burning coals and other hot materials, as well.

Is this a trait shared by other Targaryens? Her brother certainly wasn't immune to molten gold, and while a number of Targaryens were fascinated with fire (Aerion Targaryen died from drinking wildfire, believing it would turn him into a dragon), I don't recall seeing mention of any Targaryen shrugging off fire.

Is Daenerys' apparent immunity explained anywhere?

Answer: 
It does seem to be a regressive genetic trait, if it is a genetic trait, as it is not shared by all Targaryens. There are a few allusions to her apparent heat resistant qualities before the funeral pyre and the hatching of the dragons: most clear is the scene where she picks up the dragon egg that she had placed in the coals in her tent. Her hands are untouched while her handmaiden burns hers after a much shorter contact. In the book, but not in the tv series, it is mentioned she likes her bath to be hotter than most people would find tolerable. 

The other explanation is that it is Magic (add tinkly music) - the first instance when she is clearly fireproof is the funeral pyre scene. This is meant to be a magical event, though no spells are read out nor is there magic lightning effects. Magic in the world of GoT is purposefully ambiguous, not unlike Tolkien's world - there is no neat explanation anywhere what it does and does not do or how many kilojoules of willpower are needed for an effect of magnitude X. However it has been alluded that the re-emergence of dragons has made magic a more potent force everywhere

So it is largely open to interpretation my the reader/watcher, I would guess it is a bit of both. Daenerys is heat resistant by her blood heritage, but the effect is magnified by her magical link to the dragons.
While it is left somewhat ambiguous as to whether her family is inherently immune to fire, she certainly seems to be that way. While the second time she is 'burned' mentions pink and tender skin as well as sores, she herself later reflects that only her hair burned away, just like the first time. She even goes so far to try and make a hat to cover up her head.

Is she truly immune to fire? Perhaps, perhaps not. She had sores and tender flesh, but those might have been friction burns. She claims to have lost her whip somewhere along the way, if it got ripped out of her hands that would explain the sores.

What remains certain is that she was subjected to fire **hot enough to burn away her hair** and come away unharmed. If that is not total immunity to fire, it's quite possibly the closest thing you're going to get.

While I don't doubt that at one point Martin might have intended it to be a one-time deal, it clearly is not. Also, there are more hints that Targaryen blood has power in it. Ben Plumm is quite liked by the dragons. One of them even goes so far as to land on his shoulder from time to time, something they only seem to do with Daenerys. So yes, I do think Targaryen blood has some sort of dragon-affinity and Daenerys herself has an immunity to fire.