For instance, remember the second year episode "Journey to Where" in Space:1999. This episode finds Helena Russell and Commander Koenig trapped in a prison cell that is, essentially, a cave (on Earth, in Scotland, in the distant past). Helena is sick and getting sicker. But she demonstrates her knowledge and skill as a doctor by having Koenig pick fungus from the cave walls, and mix together a cure. It heals her.
In Star Trek: The Next Generation, in the first season episode "Arsenal of Freedom," Picard and Crusher are trapped in a cave. Crusher is injured, bloody and scraped. She has Picard use the roots in the cave to mix together a clotting/healing medicine, and is healed.
In both cases, the commander and doctor -- clearly attracted to one another -- are trapped together in an earthen location, and they switch roles, in a sense. The doctor leads, demonstrating knowledge and know-how, while the commander takes orders, and must assemble the ingredients of a medicine, and then administer that medicine, by the doctor's instructions.
Sometimes the same idea appears with independent authors who have no knowledge of one another.
So I'm not saying these are examples of outright theft.
I'm merely suggesting, I suppose that Space:1999 may be more influential and important a series in cult-TV history than it has been given proper credit for, especially in some (but not all...) Trek fan circles.
The example you name, is another worth thinking about, for certain. In both "Space Warp" and "The Immunity Syndrome" an alien version of the captain's log provides the clues to resolving a mystery. And indeed, this also occurs in "Booby Trap." And "Booby Trap" even gives us the alien captain skeleton, like the one in "Immunity Syndrome" (both pictured at the head of this post.)