But as they did, they didn't throw the godlike being into the plot, they made them the plot. There is a difference.
Yes. Again, it's misunderstanding the term "deus ex machina" to think it literally refers to using supernatural beings in a story. That's just a metaphor, a reference to the way ancient dramas would often resolve a plot by having the stage machinery simulate the intervention of a god. As a term of literary criticism, it refers to the storytelling cheat of resolving a problem by the sudden intrusion of an arbitrary external element that wasn't previously set up in the narrative, rather than through the actions of the story's characters.
Now, there's certainly merit to the opinion that Star Trek overused godlike beings, or that their use undermined the show's credibility. But that's not deus ex machina. That's the wrong term to use for that discussion. The godlike beings were generally used to create the stories' problems rather than suddenly resolve them.
I'd submit that the arrival of Trelane's parents at the end of "The Squire of Gothos" is deus ex machina to a degree; true, the fact that Trelane was actually a child was hinted at throughout the story, so the revelation that he has parents is not completely out of the blue, but it is a DEM in the sense that Kirk does nothing to bring about the resolution of the plot; rather, these new characters show up and put a stop to it while the hero merely stands there and watches. That's the key. What keeps something from being a DEM is that the protagonists actually do something to resolve the problem. For instance, the Prophets disappearing the Dominion fleet in the wormhole in DS9: "Sacrifice of Angels" isn't really a DEM, because Sisko convinces them to do it, so it's a consequence of his actions. And Q saving the E-D from the Borg at the end of "Q Who" isn't a DEM, because it's the result of Picard making a choice to admit humility and ask for help. The real arc of that episode is not "The crew fights the Borg," it's "Q teaches Picard a lesson about his limitations," and the resolution of that arc is when Picard confesses to needing help. It would've been a DEM, though, if the crew had stumbled upon the Borg on their own and Q had just randomly shown up at the end.
As for the actual question being raised here -- whether the godlike beings undermined the show's credibility -- I'd say yes, but as far as TOS was concerned, it was a somewhat necessary compromise for the sake of budget, much like the "parallel Earths" idea was a deliberately unrealistic notion that was necessary to make the production affordable. It's less expensive to depict aliens if they have the power to make themselves look human. And it's also inexpensive to give them telepathic/telekinetic powers, because that's the kind of thing that can be shown largely through acting and pantomime -- an actor pretends to be mind-controlled or to lose control of their body -- or through very simple special effects like jump cuts (for teleportation/transformation) or wire work. That's why we saw so many TOS episodes about characters with mind powers -- because it was cheap. When it came to TNG, with more money and better effects technology at its disposal, you could say it was more of an indulgence, just falling back into old habits.
The point of Trelane was that they had already established that it was a hard, harsh universe, based on physical laws that could not be broken or ignored... and then here's this *seemingly* magical being. It wasn't a TV gimmick. It wasn't a Lost In Space wacky device. It was an extreme weird novelty, that they then had to explain in SF terms.
No, I think the point of Trelane was that they needed to construct stories around historical props, costumes, and set pieces from the Desilu warehouse in order to save money, so they made up a story about an alien with a fetish for Earth history. The rest was just the excuse for that. It's the same reason they did episodes about gangster aliens and Roman aliens and Nazi aliens, and the same reason the later Trek shows did holodeck stories.