“I’ve tried to tell you before, scientists have always been pawns of the military.”
I can’t speak to the relationship between scientists and military personnel in Starfleet, but David’s warning to his mother, Dr. Marcus, in Star Trek II: The Wrath of Khan neatly underlines the antagonism between the eggheads and the meatheads in so much of science fiction. The scientists see the military as a bunch of trigger-happy morons, while the soldiers see the scientists as a bunch of troublemaking nerds who do more harm than good.
You can probably trace the intensity of this mutual distrust back to the dawn of the atomic age, when the militarization of science produced the means to kill everyone on earth. The animosity is certainly on full display in one of the key science fiction films of that era, 1951’s The Thing From Another World. In the film, scientists and Air Force officers stationed at the North Pole discover a wrecked UFO. They uncover a body encased in ice near the wreckage and transport it back to their base just before a storm blows in and cuts them off from the outside world. Then, of course, the thing in the ice thaws out.