Biofilms form when microorganisms like bacteria attach to a surface and produce an extracellular polymeric substance (EPS) that enables them to stick together. As more layers of microorganisms and EPS build up, they create a complex 3D structure. In wastewater treatment, microorganisms in biofilms absorb and break down organic matter, producing new cells, carbon dioxide, and water. This process removes organic compounds from wastewater as the microcolonies settle as sludge.