Long, complicated story shortened and over-simplified because the days before CGI you had to use motion controlled models which were a lot more limited in how they could be shot.
While true, the phaser beams and torpedoes were added effects, and could go at any angle, and, as discussed, they are quite capable of shooting close to straight up if not fully straight up.
However, drama is the reason they did it the way they did it. So the viewer can get a cathartic sense of "Oh, you fool, Khan!" when the Enterprise rises up like, I don't know, Rambo from underwater.
I'll toss in my two cents for torpedoes that have no guidance systems and always just miss and never seem to curve. Trek only has one example of a guided missile I can recall, and that was the custom "tailpipe" follower in The Undiscovered Country.
Of course, as with games, ships need to survive more than a few hits for drama, and you can't just have a quantum nuke blow up everything within half a light year. This means "shields" are currently the dominant war tech, which seems to be the exact opposite of the current state of warfare. Forgetting nukes and MOABs, you've got stuff that can punch through 30 feet of reinforced concrete and then explode. The amount of already-extant tech they have to flat-out ignore to give giant robots and monsters and Godzilla and aliens and tripods a shot is just mind numbing.
We may be nearing a time where missiles (and lasers) now step up to take dominance as a defensive weapon against other missiles and artillery, instead of being unchallenged as an offensive weapon.
That could alter stories as well by no longer needing to introduce magic shields.
Now it isn't literature, but if you toss in games into the problem, space games tend to implement not space flight simulation, but air flight simulation, with banking and whatnot. Except for Eve Online, which is a submarine simulation.