One is a broad base for story telling, the other is one long story about how a single family and their granddad's hetro-lifemate can fuck over an entire galaxy,
But they're mostly right about the hopeful part. When it isn't shown that the Federation is super corrupt and being controlled by evil outside forces, of course.
In 2364, when the USS Enterprise-D was unexpectedly thrust millions of light years into a realm where thoughts became reality, Kosinski described this explanation of the phenomenon as akin to being asked to believe in magic. Captain Jean-Luc Picard felt the explanation made sense, however, as only the power of thought could explain the strange events that were manifesting aboard the vessel, such as his own apparent meeting with his maman, Yvette Picard. (TNG: "Where No One Has Gone Before")
There's also a regular invocation of Clark's Law, producing a rich surplus of "Space Wizards" - from TNG's Q to Gabrielle Burnham, the Red Angel, in Discovery.
That's before you get into hyperdrives and teleporters and replicators and holodecks and other very naked violations of established science. Functionally no different than characters casting spells and using magic items in a game of D&D.