There are guard cells surrounding each stoma that cause them to open or close throughout the life cycle of the plant. This occurs in response to water and ion concentration in the plant cell, according to Pearson Education.
Transpiration is the process by which water and minerals move through a plant, and the stomata are pores through which these exchanges happen, according to Wikipedia. The main function of the guard cells surrounding the stomata is to regulate the size of each stoma's opening in order to control the plant's rate of transpiration.
The guard cells cause the stomata to open any time the plant cell has accumulated high concentrations of potassium ions. The ions trigger the guard cells to swell, which opens each stoma by changing its shape. When the guard cells lose water, the stomata close to preserve water in the plant.