The Galaxy is disc shaped because most of the stars formed in a disc. They formed in a disc because most of the gas was in that disc.
If you have a collapsing cloud of gas then as it collapses it becomes turbulent and heats up. As a result, it loses energy through radiation. However, whilst that radiation carries away energy, it carries little angular momentum. Thus, as the cloud collapses its energy decreases but its angular momentum stays the same.
This process leads to a disc-like geometry - a geometry that (approximately) minimises energy for a given angular momentum. Most of the star formation then takes place in this compressed gas disc and we end up with a disc-like galaxy of stars.
A similar process is the reason that the Solar System has a planar geometry.
Some people are happier thinking about this in terms of forces. If you go to the frame of reference of a parcel of gas$^{*}$, then the vertical structure (here, vertical means parallel to the spin axis defined by the angular momentum) and height are governed by the balance between gravitational force and gas pressure. However, in the direction perpendicular to the spin axis, there is gravitational force and opposing gas pressure as before, but also a centrifugal force acting outwards. It is this that ensures the gas cloud is extended into a disc-like structure.
The above explanation describes a simple, monolithic collapse. Many galaxies, including the Milky Way, are built up through mergers. However, the principle is the same; if the merger is "gas-rich", then the gas will settle into a disc, and then subsequently stars are born in that disc.
Not all stars are distributed in a disc. The Galactic halo stars are more spherically distributed. These are older stars and mostly metal-poor. They are the initial stars formed before the gas had collapsed into a disc-like geometry or stars that already existed in preceding, smaller galaxies that merged with the Milky Way. They stay in a roughly spherical distribution because the dissipative processes that act in a gas cloud are ineffective in a "collisionless" system of stars.
$^*$ NB You consider a parcel of gas as a whole, not the individual "orbits" of gas molecules because the mean free path of a gas molecule (before it collides with another) is very short compared with an orbit. The opposite is true for stars.