Seasons occur primarily due to the tilt of the Earth's axis and its orbit around the Sun. The Earth is tilted at an angle of about 23.5 degrees. As the Earth orbits the Sun throughout the year, this tilt causes different parts of the Earth to receive varying amounts of sunlight at different times.
During summer in one hemisphere, that part of the Earth is tilted toward the Sun, resulting in more direct sunlight and longer days, which leads to warmer temperatures. Conversely, during winter, the same hemisphere is tilted away from the Sun, receiving indirect sunlight and shorter days, resulting in cooler temperatures.
Spring and fall (autumn) are transitional periods where the tilt is such that both hemispheres receive roughly equal amounts of sunlight, leading to moderate temperatures. This variation in sunlight and temperature is what gives rise to the seasons we experience.