There's two different effects here, and they're both related to viscuous forces in the accreting matter.
First, if the infalling matter has some nonzero angular momentum vector LL, then consider a plane perpendicular to this vector. Due to its conservation, we can't get rid of rotation along this plane, but the component of angular momentum orthogonal to the plane is zero. As the accreting matter heats up and radiates away energy, that energy is taken from the gravitational potential, which is lessened by bringing the matter particles closer together. Thus, such interactions tend to flatten the matter into the plane orthogonal to its angular momentum.
But there's something more that happens for rotating black holes, as a combination of its gravitomagnetic field and viscous forces in the matter, that drives the matter to the plane of the black hole's rotation, regardless of its initial angular momentum. This is called the Bardeen–Petterson effect [1]:
In an accretion disk, viscosity causes each ring of gas to spiral inward toward the hole with a radial speed |ur|≪(orbital velocity)=(M/r)1/2|ur|≪(orbital velocity)=(M/r)1/2. If this were the only effect of viscosity, the warping of the disk would consist of a differential precession. Successive rings, each of smaller radius than the preceding, would have interacting longer with the [gravitomagnetic] field and thus would have precessed through successively larger angles... . As a result the disk would be radially twisted, but it would not be driven into the equatorial plane. However, the precession changes the disk's shear σjkσjk and thus changes the viscous forces; and these altered forces drive the disk toward the equatorial plane of the black hole.
This is only significant closer to the black hole, at r≲100Mr≲100M. At larger radii, the disk shape is due to the direction of the angular momentum of the matter instead.