Not to bring too much reality to canon here or anything... but from the perspective of a military engineer (me -- 6 years 18C):
While a sphere is indeed the shape most optimized to contain the largest volume in the smallest surface area, this is actually the worst possible thing you can do for a defensive structure. The best defensive structures look like triangles (when undermanned), and grow extrusions as resources become available (as in, angular extensions ending in a point). So a defensively optimized Death Star would look more like a giant version of the 1980's rendition of Superman's babyhood spaceship than a ball.
The reason for this is it concentrates defensive fields of fire, observation and clearly defines the line of final protective fire. At the same time this shape forces an approaching enemy into increasingly tight channelized zones within which obstacles, traps and interdiction devices can be placed, and such spaces can even serve as advantaged terrain within which to fight entire self-contained battles against the channelized enemy without threatening any worse than a breach to three extrusions at a time. These extrusions should be internally segregated from anything critical (so extrusions might house perishable storage, storage for dangerous stuff that might burn/explode, non-critical living areas, etc. while the entire extrusion should be only a conceptual "drawbridge" away from isolation from the next inner defensive wall/barrier).
Imagine being a gunner on a ball-shaped Death Star: your field of fire is greater than 180 degrees in three dimensions. Its you against literally more than half the universe. In addition, even at the Death Star's vast size, an enemy could approach quite close and still be below your meaningful horizon. The solution to this is to place defenses on towers, which now exacerbates the situation of marking a field of fire. In real life we try to limit a defender's field of fire to less than 60 degrees in two dimensions (ideally ~30 degrees along the horizon, or buttressed against a wall on one side in the case of a vertical field of observation), and ideally have the defenders shooting where one limit of fire is the wall of the defensive structure itself and the other only slightly angled from it -- this gives them a meaningfully narrow field of observation and vastly increases the chances of them firing in enfilade. The idea with fast moving targets like fighter craft is to have the enemy fly into your shots, not to try and track their course. This is a lot easier if their path of egress is limited by physical barriers instead of having over 180^3 degrees of freedom.
In a fight against small, fast-moving, highly-maneuverable fighters this is optimal -- it deprives them of their speed and agility. In a fight against large cruisers it would probably also be an ideal layout because scoring a critical, large hit would be difficult, as everything important is deeply nestled within the prongs, drastically limiting the opportunity for a meaningful hit on target for a capital ship.
The star-like shape I am describing is actually the way that firebases (well, when a competent engineer is involved -- not always the case), patrol bases (at least when real infantry do it), and even castles and coastal defenses going back hundreds of years have been built. "Round" is a maximally taxing shape from a defensive engineers point of view and an attacker's dream come true.
All that said, I doubt that anybody involved in the production of Star Wars was a infantryman, a military engineer, or had ever taken machine guns 101. To stay in-universe and give a reason, however, requires some pretty creative thinking. Looking at the project from a cost point of view, a sphere might be quite attractive. Looking at it from an energy conservation point of view this may also be the case, as extrusions would massively aggravate the amount of energy required to overcome rotational inertia and actually aim the thing (all that angular momentum stuff you learn about in school -- not that Star Wars seems to pay this much mind elsewhere). In short, anything other than a spherical Death Star would be very costly to aim.
Could cost + maneuver budget + the Emperor's self perception of invincibility* be enough to motivate a spherical design? I don't know -- but from a defensive point of view, it is a critical blunder. But we already knew the design was flawed the first time we saw Luke blow the thing up in an X-Wing!
(* This point being debatable with regard to the Emperor himself, maybe, but certainly stands for the sneering officer that Darth Vader choked out in the briefing room -- and I assume this reflected the majority opinion of fleet officers everywhere. Wouldn't you feel proud to thump your chest if you had a Death Star? Even a round one?)
Anyway, it bears mentioning that the Death Star was not a defensive weapon in concept.
Edit: Adding a few references. There is no online version of the old A-Camp manual (Pappy Jones!), but the above (and a thousand other related) issues are discussed there at length.
Edit: Thoughts on deflectors/shields prompted by a comment from @RonLugge :
I am not a Star Wars canon expert, but I'll make two big assumptions here
- That shields cost less than the things they protect (otherwise they would not be cost-effective)
- That shields cannot be projected through one another (we never see layered shielding in the movies)
If these two assumptions hold then a star shape is considerably better than a sphere. The outer shield of the Death Star still serves its original purpose and shape. Following the two basic defensive rules that 1) a single layer of defense is no defense, and 2) unmanned obstacles are not obstacles, it is absolutely necessary to physically harden the outer portions of the extended spikes with ablative material*, and most critically, place deflector shields in layers between and among the defensive extensions. This not only makes attacking the Death Star an onion-cutting problem for a large scale fleet attack (the main scenario against which the Death Star's original defenses were supposedly designed), but also provides the Death Star the chance to literally parcel up a large fighter swarm attack into trapped segments which are much easier to deal with.
Considering the immense size of the Death Star and the (almost ludicrous closeness of Star Wars space battles), though, the star-shape would actually be able to physically disrupt formations of capital ships as well. I didn't consider this until I saw an image of a super star destroyer drawn to scale against the Death Star -- at 19km in length, the super star destroyer looked positively tiny.
(* Ablation being drastically improved by the dynamic expanded surface area of any shape other than a sphere -- which is why we don't buy spherical heat-sinks for our computers.)
The main deflector now becomes much more than a simple shield: it can now be used as a tactical element of enemy formation disruption by selectively switching it off to deliberately permit a portion of the attacking formation to enter, and then turning it back on to cut them off from assistance.
Gauging the optimal size of an enemy formation to attack is a tactical issue, but this is the basic idea behind disintegrating tank and infantry defenses, use of double-sided sally ports and the like in ground warfare. A similar technique has been used in real aerial battles, where ground-to-air defenses are deliberately left hidden and unengaged until a selected portion of the enemy formation has crossed them (the fighter screen advancing ahead of a bomber formation, for example) to deliberately isolate a "manageable" formation from the main support body and disrupt the main attack (the bombers) or strip it of its air-to-air support.