Sure, Trek's given us plenty of episodes where a ship fires phasers from orbit and destroys something on the ground, because TV writers don't understand science.
That's not really fair. There's nothing wrong
with phasers being strong enough to reach targets through a couple of hundred kilometers of air as such - it's just a question of numbers. And we know when the numbers get too big for phasers: in "Extreme Risk", the phasers of the Voyager
could no longer destroy the compromising probe when there was 10,000 km of air between it and the ship.
Pursuing the E-D into the atmosphere was nevertheless a satisfying twist, because it brings a bit of realism to the ability of a teeny weeny device to threaten a giant starship. Phasers seem to benefit greatly from being used at point blank ranges even across vacuum; one might deduce that they rapidly lose power over distance, regardless of the medium (although having a medium might still make things even worse), and a tiny assailant would need to make the most of the advantage provided by reduced range.
As for the general method of "fighting in a burning house", it should really only work against really obsessed pursuers who are out of options themselves and cannot wait for your demise outside the burning house. Some of the Trek examples qualify, others do not. And players like the Borg are just plain nuts anyway.