Galaxies are flat, disc-shaped because a disc is a natural equilibrium between a spinning angular momentum force trying to push material outward and a gravitational force trying to pull it inward. As the galaxy rotates and is compressed by gravity, celestial objects inside are sent outwards, giving a galaxy its flat look. Because of the massive force that spin produces, every object within each spiral galaxy remains shaped in the form of a disc.
This is one more factor that causes spiral galaxies to begin developing flat shapes when major axes begin forming accretion discs. Galaxies develop disc shapes as gas, which makes stars fall in the shape of the disc. Their stars are usually ancient, having formed before there was just one flat rotating plane, so we find spiral galaxies outside of the plane of a galaxy within star clusters.
The majority of stars in spiral galaxies are located near the flat plane (the galactic plane) in roughly regular circular orbits around the center of the galaxy (the galactic center) or a spheroidal Galactic bulge surrounding the Galactic nucleus. Most spiral galaxies are composed of a flat, rotating disc that contains stars, gas, and dust, with a central concentration of stars known as a blob. The galaxies we see today are flat, as their stars formed only in a flat, rotating plane once created.
Galaxies did not eventually become as spherical as planets because the distance between the spin center and the arms kept objects balanced, with stars either orbiting around the black hole or spinning about the core but not being pulled all the way to the nucleus. Ellipticals appear that way due to the gravitational forces creating the centrifugal reaction, which causes galaxies to spread outwards in a flat-like shape. When disk-shaped galaxies hit each other, that may perturb star orbits, and what you end up with is a blob-shaped galaxy; those are called elliptical galaxies, which are pretty common.
Given what we know about galaxies generally, until now, it made sense to think that the Milky Way might be something like our neighborhood neighbor, with its neatly ordered spiral arms. Another galaxy got overly close, and this galaxy pulled stars out of the Milky Ways disk toward itself using its gravity, distorting the gaseous disk and the star arrangements along with it. Geth revealed that this disturbance of the Milky Way goes around the whole thing once every 440 million years.