Smokeless powder is composed primarily of nitrocellulose, sometimes with a bit of nitroglycerine added (double base powders), but also contains several other organic chemicals. There is always a bit of residual solvent (perhaps 1-3% by weight), which will be ethyl acetate in Ball powders, or a mixture of ethanol and diethyl ether in IMR-type powders. Sometimes other solvents like acetone are used in applying deterrent coatings, and will still be present in small quantities in the finished powder. Deterrents can be of several sorts, some of which are themselves energetic (but oxygen-deficient) compounds like 2,4 dinitrotoluene (used on most IMR type powders), and some of which are "fuels" with no oxidizing groups in the molecule, like the dibutyl phthalate used on most Ball powders. There may be anywhere from 4-10% deterrent by weight in typical powders. Then there are stabilizers, like diphenylamine, 1-2% by weight. Some powders contain additional plasticizing or "gelatinizing" agents, like camphor (found in some Russian powders) or centralites. All of these are organic compounds rich in carbon and hydrogen with insufficient oxygen present to burn them. They all vaporize in the heat of the powder's deflagration and are present in the gas mixture produced. Nitrocellulose itself is oxygen deficient to varying extents, depending on the degree of nitration. The gases produced when it decomposes include carbon dioxide, water, nitrogen, carbon monoxide, and hydrogen. The last two of these are fuel gases. Nitroglycerine decomposes to carbon dioxide, water, nitrogen, and free oxygen, but it only releases a net amount of one oxygen atom per molecule of NG. NG is usually a minority component of powder if present at all, so even double-base powders are still quite oxygen-deficient.
Whenever a charge of smokeless powder is fired in a gun, this mixture of fuel gases containing the combustible products of nitrocellulose and a considerable amount of organic vapors from the solvents, deterrents and stabilizers (and compounds produced from them by thermal "cracking") is produced, and this flammable cloud blasts from the muzzle. When it does, it mixes turbulently with surrounding air containing oxygen. If it's hot enough and remains hot long enough for autoignition, this mixture can explode and make a bright flame resulting in a "secondary muzzle flash." This is the big showy bright orange-white flash sometimes seen. The primary muzzle flash is from the incandescence of the heated gases and suspended particles, like the little orange-red squirt from a shotgun or .22 rifle at night. (You would see that on the moon, but no secondary flash.) You don't always get a secondary flash, because the gases may already be cooled too much from expansion within the bore for igniting during the very brief time before they cool well below ignition temperature from further expansion and mixing with cool air, they may be rapidly cooled by being broken up into small jets by a flash-suppressing muzzle attachment, or they may contain flash-inhibiting substances like potassium salts (like the ~2% potassium sulfate found in IMR powders) that inhibit the free-radical chain reactions initiating the explosion. (This action is just like what tetraethyl lead did to prevent "knocking" in engines using leaded gasoline.) Other factors like the presence or absence of glowing sparks in the muzzle cloud can influence ignition, as well. Given the relatively small quantities of powder used in small arms cartridges, the delay time involved in autoignition of the gas/air mixtures, and the rapid cooling that occurs in the exhaust cloud at the muzzle, secondary muzzle flashes are more the exception than the rule (and can be quite entertaining), but they're a big problem with artillery. You'll see secondary flashes a lot more when using heavy charges of slow-burning powder, not because powder's still burning outside the muzzle, but because the gas temperature is higher when the bullet exits the muzzle with these loads. The solid powder extinguishes almost instantly when the pressure's released and contributes little to the flash. And individual powders will differ in their flashing tendencies due to differences in composition.