The show simply doesn't answer this, but I think we can come up with an answer by observing the dragons' behaviour and comparing it to other animals which we understand better.
The short answer is that they are intelligent and loyal creatures.
Let's jot down a few things that we know about dragons:
- They are intelligent (Tyrion claims that they are more intelligent than some humans)
- They can understand language
- At least simple commands but;
- Possibly more complex language such as a strategy or plan (such as when they destroy only some of the Masters' ships)
- They are loyal to their master/rider (they always respond to Daenarys and history tells us that dragons in the past were loyal to their Targaryen masters/riders)
- There is no reason to think that they are spiteful or hold grudges for punishments
- They cannot be truly tamed (according to Jorah Mormont) but they are clearly tamable at least to a large degree
Now compare dragons to something like dogs. If you punish a dog, even going so far as to lock it up for a time, when it comes out it still loves its master. They aren't vengeful. More than just a master or rider, Daenarys describes herself as the mother of dragons. You always love your mother (this is even true in many animals).
Drogon especially, seemed pretty unresponsive to her
The dragons were young (like puppies). I think this might explain their unresponsiveness and bad behaviour. Towards seasons 5 and 6 we see the dragons are much more mature and less playful (think back to when they fight each other over food - like young animals might).
Drogon seems to show up at the most convenient times
There isn't much in-universe explanation for this except that, as you say, it's convenient. The out-of-universe explanation would be that it has significant dramatic effect.