The most rational shape though would be a cylinder with its height equal to it's diameter as it's been demonstrated mathematically that it's the shape that minimizes the surface of the hull for a given volume. The less hull you have to protect the less vulnerable you are to an attack.
Actually, a sphere would have an even more advantageous ratio (which is why soap bubbles are spheres rather than cylinders). It's a somewhat awkward shape for many vehicles, but spaceships would do well with it.
OTOH, you could also choose the flat Starfleet saucer because (when you have Trek-style "down-pointing" artificial gravity, by whatever means, be it magically pulling floors or the acceleration from your engine) a cylinder of any height gives you more standing-height volume than a corresponding sphere (which suffers from compound curvature); the narrow edge of a maximally flat cylinder minimizes your profile against the enemy (assuming you can maneuver to present that profile to him); and sometimes you also want to
maximize your surface area (say, if you want to catch or dissipate radiation in a particular direction).
Of course, Star Trek has come up with its own rationalizations for the weird shapes of starships, even if these aren't explicit in the dialogue. We see graphics of warp field shapes, and those are not just exotic but supposedly also quite confining in terms of Trek pseudophysics. OTOH, we see ships of any and all shapes, suggesting that there are many warp field shapes to choose from. But spheres and cylinders and other simplistic shapes are extremely rare, suggesting the engineers put high priority on optimal warp field shape and can do little with hull shape as a consequence. Tellingly, the ones using the simplest shapes are the Borg, the masters of the brute-force approach...
There's a popular fan theory that she is still undergoing those trial runs throughout the first season
...And then there's ST:FC where the next
Enterprise has also been out in space with the usual heroes aboard for a full year, but everybody is still itching for the beginning of actual action. Quite possibly, Starfleet believes in shakedown years in a fairly demanding environment!
Timo Saloniemi