The mineral composition of a rock reflects the physical environment and geologic history where a rock formed.
Rock form in a variety of geologic setting ranging from locations on or near the earth surface, deep underground, or even in outer space. Most of the rocks we see on the surface of the planet formed by processes that happened long ago, but we can see these processes actively taking place in many places.
Rapid rock formation can be seen happening such as lava cooling from a volcanic eruption in places like Hawaii or Iceland. However, most rocks we see around us form very slowly in settings that are not visible on the land surface.
Slow processes creating rocks can be inferred by observing reefs growing in the oceans, or sediments being carried by flowing water in streams or moved by waves crashing on beaches. We can see sediments being deposited, but we cannot see them turning into stone because the process may take thousand or even millions of years.