Microbial mats are multi-layered sheets of microorganisms -- mostly bacteria and archaea (another domain of bacteria-sized microbes) that dominated much of the planet for billions of years, before the evolution of multicellular organisms, which promptly ate those microbes up as soon as they arrived on the scene. Microbial mats are often found at the interface between two substances, especially in moist or submerged environments, such as the sea floor. These microbial mats are held together by extracellular polymeric substances -- also known as scum -- which reinforce their structure and adhere them to the substrate.
Fossil evidence of microbial mats appears as far back as 3,500 million years ago, serving as the earliest direct evidence of life on Earth. Initially, the microbes in the mats were chemoautotrophic -- meaning they got their energy and carbon by combining together chemicals found mostly at hydrothermal vents on the ocean floor. Then, about 2,600 million years ago, the microbes evolved photosynthesis, they could expand out of the "hydrothermal ghetto" into a much broader range of environments, especially the top 100 - 300 m (328 - 985 ft) of the water column, known as the pelagic zone, and any stretch of sea floor with available light.
Microbial mats are the context within the first multicellular organisms evolved. Some scientists argue that the earliest multicellular organisms, the Ediacaran fauna, lived affixed to the mats and gained their energy through symbiosis with algae, distributed throughout their bodies. At least, that's what seems plausible, as Ediacaran organisms lack a gut or any obvious feeding apparatus. In what is called "life on the mats," mobile organisms initially evolved as burrowers in the mats, digging shallow horizontal burrows through them, some of which are preserved to this day.
During the Cambrian period, about 542 million years ago, there was a "bioerosion revolution" which occurred when mobile animals expanding their size, complexity, and suite of behaviors. In fact, complex vertical burrows -- absent in the previous Ediacaran period -- are part of the official definition of the start of the Cambrian, along with the appearance of ubiquitous organisms known as the small shelly faunas. These complex burrows marked the beginning of the end of the microbial mats, which could no longer afford to exist as such a concentrated food source out in the open. Today, microbial mats are only found in areas devoid of most other life, such as thin crusts in deserts, in very briny water, or in the deep reaches of the ocean floor.