What causes the color difference of lightning flashes?

First I thought to point to an old answer but I have then realised that it is not really a duplicate. However it does support what I was thinking to write (I am not a specialist of atmosphere physics), at least for the part concerning

what causes the lighting to, as for its name, emit light.

The visible part of the lightning, that we can consider as a spark of very big length size happening in not well controlled conditions, is a tiny ribbon of plasma surrounded by a hot and thermally ionized atmosphere envelope that the plasma itself generates.

Thus, a lightning does emit light both

  • thermally, which leads to a continuum and T dependent spectrum of the black body type

and

  • via emission by plasma recombination and by the radiative relaxations of the species excited by the plasma itself.

See Why does lightning emit light? for more details.

Now, there is not reason to think of a changing atmosphere composition, except for the water content (humidity). We are in a safe (and indeed easy) side if we stuck to the famous 80/20 ratio.

On this basis we should expect the intrinsic colour of a lighting to be hot white, as for according to a variety of sources its T spans the range 30000 - 50000 K.

Of course a spectrographic analysis of this white light does reveals superimposed characteristics emission lines, those mentioned above and which are the subject of another answer* in this thread, but those should not influence our perception of the colour. In other words our eyes are overwhelmed by the bright thermal radiation.

Why we see lightnings of different colours?

Why then sometimes lightings appear to us in a variety of colours, white, more bluish, reddish etc?

One point are well known scattering phenomena, especially those related to particulate and droplets - Mie regime. The intensity of this scattering will depends on the actual atmospheric conditions and always increase with distance (as the thickness of the atmosphere increases). Assuming a homogenous and vast enough portion of the atmosphere, lightings at horizon will be reddened (to the extent of appearing yellow) as compared to nearby ones, just to give an example.

Several specific examples are given in the last part of this webpage https://uvhero.com/what-color-is-lightning/

A second point, often ignored when discussing about colours, is perception. I won't refer here to CIE coordinates and the like, but I want to point out that the appearance of an object as perceived, including its brightness and colour, depends upon the surrounding. Just think at the moon. Given the same illumination by the sun, it certainly looks glowing, bright, and yellow at night, while it seems grey-white and opaque rock during day.

Similarly, the same lightning in the same diffusive atmosphere would look differently at twilight or at night, bluish against a bluish sky, and bright whiter against a black one (though admittedly this very last is me guessing at the situation :)

*meantime edited to be more sensible