Why are accretion disks flat?
Conservation of angular momentum.
An accretion disk is formed by matter being gravitationally pulled toward a mutual center, causing it to orbit. A solar system forming around a protostar, matter falling into a black hole, and even the rings of Saturn can be considered forms of accretion disks.
Objects that are captured in a gravitational orbit have angular momentum. In other words, there is some degree of rotation that will be maintained without further interactions with other particles. Collectively, there is an average angular momentum for all of the particles that are orbiting.
Furthermore, these orbits can be considered to take place in some plane around the center. Multiple particles will orbit in multiple planes, and where these planes intersect, there is a possibility for collisions. Consider an orbiting cloud of particles.
As particles collide, they will redistribute their angular momentum. Some particles will be knocked into orbits that are farther away from the center.
Meanwhile, the top and bottom of the cloud are able to settle into less collision prone orbits in the expanding disk. Eventually the cloud will be stretched enough to form a flat disk around the center of mass.