The Sun appears to move across the sky during the day due to the rotation of Earth along its axis. Because Earth rotates from east to west, the Sun first appears on the eastern horizon and then moves westward across the sky until it falls below the western horizon.
The length of a day is equal to the amount of time it takes Earth to complete one full rotation around its axis. Although the Sun is not visible during the night, it continues to move westward along with the rotation of Earth. Instead, the movement of the stars at night mirrors the movement of the Sun during the day.