Galaxies form spiral shapes primarily due to the effects of angular momentum as matter coalesces, resulting in a natural disk formation. The spiral structure likely arises from matter accumulating at irregular intervals, which then gravitates toward the nearest mass. This process creates regions of increased gravitational attraction, leading to further accumulation of matter. As more material gathers, the gravitational pull intensifies, promoting the spiral shape. Ultimately, the dynamics of gravity and angular momentum explain the formation of spiral galaxies.