I noticed this too. From time to time they just break off from the dogfight and straightline for the megaship. Maybe this is to simulate some kind of "attack run" on the megaship, but it feels more like baiting me to hit the megaship to me

.
What I actually think is happening here, is that the human NPCs in these station conflicts obey their programming to not stray too far from the center of the CZ (unlike those pesky Thargoids) which will be placed at the megaship, thus they straightline it back to there once reaching a certain distance, ignoring all else including you blasting the heck out of them.
Normally that isn’t a problem since the CZs are in big open space, other than looking a bit stupid that the [insert ship] you’re blasting the rear end of, but if there’s a megaship there that gets offended the moment it is tickled with a stray multicannon or similar round…
… you get the idea. I think Frontier either needs to make it like the installations or megaships in scenarios where accidental hits don’t immediately make it hostile or even award a fine, or just turn off station guns outright if they don’t want to (or aren’t able to) do that, or or tune them down to a level where they can be avoided and survived for some time [this would maybe also get around the problem of “Why is the ship/station not engaging its attackers*”, which wasn’t an issue with AX because Thargoids take a lot less damage from human weapons].
Or (or or) do the thing they did in Thargoid CZs and disable station retaliation entirely**. When the CZs are lawless already to allow shooting of human opponents freely, it’s not as if the port will shoot at someone just there to blast another player with no Powerplay or CG opposition in mind.
*It is also rather silly how the actual military capital ships are generally seen as pushover jokes acting as punching bags in CZs, but station lasers are so powerful to obliterate any regular ship of any size and outfitting within seconds such that actually attacking them with the intent of disabling or seizing it would be downright suicidal, for any force that isn’t ready to throw massively over the top numbers at it and to probably lose more ships in a few minutes than they would attacking a Thargoid Titan.
**Shard cannons against Scouts that are shooting a starport can be inaccurate sometimes, ok?