It has to do with the fact that atoms and molecules that are heated in flames can absorb some of the heat energy and then promptly spit it back out as light energy.
Every substance has its own typical wavelengths or colors of light that it emits after being stimulated by the heat. (Techspeak: every substance has its own unique emission spectrum.)
The propane or natural gas in your gas grill and the acetylene in the welder’s torch are very similar; they are all hydrocarbons, compounds of carbon and hydrogen. It happens that hydrocarbon molecules emit many of their particular light wavelengths in the blue and green parts of the visible spectrum.
Other kinds of atoms and molecules, if they were vaporized and burned, would impart their own particular colors to the flame. That’s how colored fireworks are made.