(covers information from several alternate timelines)
The environmental controls of a starship, space station, or even a colony were used to regulate atmospheric conditions including, but not limited to, the concentration of varying gases, lighting, temperature, humidity, and gravity.
Environmental controls were often used to deploy certain chemicals ship-wide or station-wide. This was done for both benign purposes, such as the release of a retrovirus to cure a ship-wide epidemic, (TNG: "Genesis"; VOY: "Macrocosm") or for more aggressive purposes such as the release of a general anesthetic. (ENT: "Chosen Realm"; TOS: "Space Seed"; TNG: "The Hunted", "Clues"; VOY: "Message in a Bottle"; DS9: "Tacking Into the Wind")
Aboard Federation starships and space stations, it was typical for there to be limited access to environmental control within crew quarters in order to meet the varied living requirements of these multi-species structures.
In the 2250s, aboard Constitution-class starships like the USS Enterprise, environmental details were displayed on the outside door controls to crew quarters. Spock's quarters were set to 14% CO2, 92% pressure, 22 °C. (DIS: "Brother")
On a larger scale, environmental controls could be integrated into a Weather Modification Net or weather control system in order to regulate or moderate global weather. (TNG: "True Q", "Sub Rosa", "Force of Nature"; DS9: "Let He Who Is Without Sin...", "Honor Among Thieves"; VOY: "Warhead")
When Chief Engineer Geordi La Forge left the USS Enterprise-E to make repairs on Zefram Cochrane's Phoenix in April of 2063, he named Lieutenant Paul Porter as being in command during his absence. He also ordered Porter to check the environmental controls, as it was warm in engineering. (Star Trek: First Contact)
Aboard an NX-class starship, the environmental controls could be operated from a dedicated console in the situation room. As part of a plan for Starfleet to retake the NX-class Enterprise from a Triannon takeover in 2153, the vessel's environmental controls were temporarily rerouted in order to spread a gaseous chemical agent throughout the craft, neutralizing organic explosives inside the Triannons' bodies. (ENT: "Chosen Realm")
In 2373, an attack by the Tak Tak disabled the secondary power couplings on the USS Voyager, preventing Captain Kathryn Janeway from accessing environmental controls to distribute an antigen to the macrovirus. (VOY: "Macrocosm")
In 2374, a group of Romulans hijacked the USS Prometheus and killed all the crew. The Doctor sent the EMH Mark II to Jefferies tube 17 where the environmental controls were located to release neurozine gas into the air system so they could retake the bridge. The EMH Mark II had never accessed a Jefferies tube and The Doctor told him that, traditionally, such a Jefferies tube was accessed head first. (VOY: "Message in a Bottle")