Several good points in the other answers. I'm here just to point out Daenerys' strategy in King's Landing battle, which counted a lot as to why Drogon didn't get hit.
0 - The element of surprise, as already pointed out by others - Drogon/Daenerys were not taken by surprise, they knew where the enemies were and what was their weapon.
1 - Being a hard target - in the first strike on the iron fleet, they are coming in an angle that the iron fleet can't see - they're coming directly from the sun. They show the audience that by having a scene with oversaturated light and the sun behind Drogon, and also by showing the sailors squinting when looking upwards to try to see them. It gets really hard to target something that's towards the sun.
2 - Being fast - since they were coming downwards, they could achieve a faster speed, arrive at their targets faster, not giving them time to aim properly.
3 - Close battle - close proximity fight is to Drogon's advantage. Drogon is big ("easy" target from a distance) and his attack range is way smaller. He has more speed and manoeuvrability. In a fight against so many scorpions, the challenge is to get close; once they're close, it's Drogon's advantage.
4 - Attack vector - with the city in the middle, all scorpions were pointing outwards. Once Daenerys destroys the iron fleet, they can fly into the city more easily, as all other scorpions are pointing away from them. They can turn, of course, but it's a slow operation. The scorpion operators heard explosions, but didn't realize Drogon was upon them until it was too late. Also, pointing the scorpions towards the city is dangerous, as you might hit your own people/buildings/Queen, so they probably would be thinking twice before doing that unless they had visual confirmation of their target.
So to summarize, yes there are all the points the others mentioned; but using your resources wisely also counts, a lot!