You're cherrypicking a few similarities and ignoring many differences. In "Errand of Mercy," a war had just started with a newly introduced enemy and the protagonists were sent to a strategically important planet to protect what they thought were its primitive natives. In "The Nox," the protagonists came to the Nox's planet in pursuit of the secret of invisibility, whereupon their already-established enemies happened to arrive and attack them. In the Trek episode, the Organian village is taken over by the Klingons and Kirk and Spock impersonate villagers and mount a guerrilla campaign. In "The Nox," the heroes are all killed by the Goa'uld and wake up in the Nox village, along with a Jaffa soldier that Teal'c knows and tries to win to his side; the village is never taken over by the Goa'uld because the Nox keep it invisible.
So yes, there are similarities, just as every story ever written has similarities to earlier stories, because all fiction is built around recurring tropes. But they're obviously not "identical." If you find it so anomalous for two or more stories to have similar themes and tropes, then you clearly haven't read or watched enough stories.