Sundogs, light pillars, and other kinds of halos seen in the sky are atmospheric phenomena that occur when light is reflected or refracted by ice crystals in the atmosphere.
What causes a halo?
Halo is the name for a family of optical phenomena produced by light (typically from the Sun or Moon) interacting with ice crystals suspended in the atmosphere. Halos can have many forms, ranging from colored or white rings to arcs and spots in the sky. Many of these appear near the Sun or Moon.
To better understand how the atmosphere produces these bursts of color, we need to understand a little something about light.
Light is electromagnetic radiation with wavelengths visible to the human eye. This is the light we see. Visible light is composed of all the colors of the rainbow.

We can see these colors by using a prism. The properties of a prism allow it to break visible light into its component colors, ranging from the darkest reds to the deepest violets and everything in between.

In the atmosphere, under certain conditions, water droplets and ice crystals can act as prisms, allowing us to see the various colors that make up visible light. It’s because of these properties that we get various atmospheric optical effects.
To better understand how the various atmospheric optical effects manifest, it helps to distinguish between refracted and reflected light.
Reflection

Reflection of light occurs when waves encounter a surface or other boundary that does not absorb their energy and bounces them away from the surface. The light is not separated into its component colors because it is not “bent” (refracted), and all wavelengths are reflected at the same angle.
Refraction

Refraction is the change in direction of a wave (in this case, light) due to a change in its speed. This is most commonly observed when a wave passes from one medium to another at any angle other than 0° or 90°.
So, when light is refracted inside an ice crystal or water droplet in the air, it’s broken into its component colors. This creates a rainbow effect.
Sun & Moon Halos

Sun Halos, and halos in general, are a sign of high, thin cirrus clouds drifting 6 kilometers (20,000 feet) or more above our heads. These clouds contain millions of tiny ice crystals. The halos you see are caused by both refraction, or splitting of light, and also by reflection, or glints of light from these ice crystals. The crystals have to be oriented and positioned just so relative to your eye for the halo to appear.
That’s why, like rainbows, halos around the sun – or moon – are personal. Everyone sees their own particular halo, made by their own particular ice crystals, which are different from the ice crystals making the halo of the person standing next to you.

The prism effect of light passing through these six-sided ice crystals also separates the light into its various color frequencies, making the halo look like a very pale rainbow, with red on the inside and blue on the outside. A 22° halo may be visible on as many as 100 days per year—much more frequently than rainbows.
There is an old weather saying: a ring around the moon means rain soon. There’s truth to this saying because high cirrus clouds often come before showers.
Sundogs

Sundogs are colored spots of light that develop due to the refraction of light through ice crystals. They are located approximately 22 degrees to the left, to the right, or both, from the sun, depending on where the ice crystals are present.
The colors usually go from red closest to the sun, out to blue on the outside of the sundog. Sundogs are also known as mock suns or parhelia, which means “with the sun”.
Sun Pillars

Sun Pillars appear as a shaft of light extending vertically above the sun, most often at sunrise or sundown. They develop as ice crystals slowly fall through the air, reflecting the sun’s rays. Look for sun pillars when the sun is low on the horizon, and cirrus clouds are present.
What’s that dot in everyone’s photos?

It is simply the bright light from a relatively small object reflecting inside the glass of your camera lens. It often appears as a dot, and many times it has a partial circle or oval with a glow around it. It might also be tinted blue, purple, or even green!
Bright lights like the sun often leave reflections and other artifacts inside a camera lens, such as a dot. These are called lens artifacts or lens flares, and they happen in all photography. It’s more noticeable when any part of your lens is flat- like the outside of a camera phone lens, or the flat lens filter many photographers use on DSLRs and even film cameras.
A more technical explanation: The lens elements in a camera contain anti-reflection coatings (thin films). Although they are intended to remove all internal reflections, they are not perfect. Their effectiveness generally depends on the incident angle and wavelength. When you photograph an intense light source, such as the sun, the small amount of reflected light is enough to appear in the photograph, and the color indicates the wavelength dependence of the particular coating. (StackExchange)