Sun dogs, illustrated above, are an atmospheric phenomenon resulting from tiny ice crystals in the air. In fact, they are part of a halo or parhelion around the Sun (or Moon), at an angle of 22° from it. This halo is typically intensified to the left and right of the Sun, forming the two “dogs” (and sometimes also intensified above and below). An explanation must therefore come in two parts – why the halo, and why the intensification?
For the first question, the tiny ice crystals floating in the air over wintry landscapes act as tiny prisms, deflecting the light by about 22° (see the diagram below, superimposed on a microscope image of an Antarctic ice crystal, by Hannes Grobe):
Because prisms deflect different colours slightly differently (as shown below), a slight rainbow effect is sometimes visible in the 22° halo, with red on the inside. However, because the deflection actually occurs over a range of angles from 22° upwards (depending on the orientation of the crystals), the blue and green colours are usually completely washed out.
The second question was: why the intensification on the two sides of the sun? This occurs because flat ice crystals have a tendency to fall through the air like paper plates, with the hexagonal surfaces at the top and bottom. Intensification above and below the sun is sometimes also seen, forming a kind of cross. This results from other, rod-shaped, ice crystals which are oriented with their long axis horizontal.
The diagram below shows the two kinds of ice crystal:
I have not been fortunate enough to see sun dogs myself, but it’s on the bucket list.