From the earliest times people have regulated their lives by the apparent motions of the Sun and the shadows cast by its rays. We say 'apparent' because of course it is the rotation of the Earth on its axis which causes the moving shadows we observe every day. When the Earth rotates 15° it is just as though the Sun had moved 15° around its daily track. Diallists use both conventions but it is usually easier to regard the Sun as being in motion
Perhaps the best place to begin an understanding of how sundials work would be to imagine a pictorial view of the Earth at the North Pole In this diagram it is the Sun which seems to move at 15° every hour. The shadow-casting element of a sundial is usually called the 'gnomon' of which the edges are its 'styles'.
This is what it would look like staring down at the North Pole from above as the earth rotates.
Another way to visualise the sundial is like this, with the gnomon pointing to the pole and the numbers around the equator. The earth moves 360 degrees in 24 hours, so the hour lines would be spaced 15 degrees apart.
Now imagine this model of the earth at various positions around the earth, at the poles and the equator and also part of the way around.
For a person on the ground, it would look like this, or if you make an equatorial sundial, like this on the right. The dial face is parallel to the equator, and the style of the gnomon points North (or South if you are in the southern hemisphere).