Classic sci-fi was far from universally optimistic, it had more optimistic pieces than we do today but I'd still say on the whole it was more dystopia than utopia. Even for its own time, the original Star Trek was considered uniquely optimistic, though a large part of that is that its just much easier to write a good story where the setting itself provides the necessary challenges for a story to work, rather than an optimistic setting which rules out a lot of the usual challenges. Even Star Trek struggled, a good chunk of its stories are about encountering a race or civilisation without that utopia, turns out telling a good story without any conflict is pretty tough, especially a long running one.
But it does more generally reflect how society views technology as a whole too. People are generally a lot more pessimistic about new tech now, myself included, we've seen time and time again how its used to control or squeeze us. There actually was a Star Trek episode, "The Game" (season 5, episode 6) about an addicting device you could compare to smartphones (though the device in Star Trek doesn't spy on you to sell your every move to advertisers, missed a trick there), and that certainly wasn't supposed to be an optimistic look at technology, so you can see why things have gone the way they have.