In general, the sun rises in the east and sets in the west because of the Earth's eastward spin. However, depending on where the observer is in relation to the equator and the time of year, the sun rises and sets either to the north or to the south of due east and due west. In fact, it is only on two days, the spring and fall equinoxes, that the sun rises due east and sets due west.
The Earth spins around its axis once every 24 hours, and it is this motion that makes the sun, the moon and the stars appear to rise and set every day. However, because the Earth is inclined at an angle (23.5 degrees), its poles tilt towards or away from the sun depending on the time of year. For an observer in the Northern hemisphere, this means that in summer, the sun rises in the northeast and sets in the northwest, while in winter, it rises in the southeast and sets in the southwest.
On the day of the summer or winter solstice, the sun rises and sets at its most northern or southern location. How far north or south the sun appears on the horizon on any give day depends on latitude. For example, as one travels farther north in winter, the sun rises and sets farther to the south. In fact, beyond the Arctic Circle, there are days in December when the sun never rises above the horizon, conversely there are days in June when it never sets.