Deserts tend to get very hot during the day because they receive high amounts of direct sunlight, but they also tend to get very cold at night. This is because deserts have low humidity levels, which means that they are unable to retain heat.
During the day, the sun heats up the desert ground and the air around it. However, as the sun sets and the desert cools down, the heat stored in the ground is radiated back into the atmosphere. In areas with high humidity levels, this heat would be trapped by the water vapor in the air, but in deserts, the dry air allows the heat to escape into space, leading to rapid cooling of the desert environment.
Additionally, deserts tend to have very low levels of vegetation, which means that there is little plant cover to retain heat and insulate the ground. This means that the ground cools down quickly at night, which in turn cools the air above it, leading to the cold nighttime temperatures that are often associated with desert environments.