The reason why different woods affect the tone is because of their density and resonance characteristics.
Let's start with a string vibrating in the air. The sound from that string is as harmonically pure as you're going to get. All the overtones are present, and it will sustain for a very long time. But it's not very loud, because it's not moving much air.
Once you anchor that string to any object, some of the string's vibration energy is transferred to the object, and it will resonate sympathetically with the string's fundamental frequency and overtones.
Acoustic stringed instruments work by transferring that vibration energy to a hollow box, which vibrates a greater volume of air, which vibrates our eardrums more. Solidbody guitars still resonate (some more than others) but the majority of the amplification is done electronically rather than mechanically.
The tone of an acoustic instrument can be shaped by the physical shape of the sound box (the body), the materials used, bracing patterns, etc. The tone of an electric guitar is shaped to a lesser degree by the materials and construction methods, but it's still a factor along with the pickups and other tone-shaping electronics.
Harder, denser materials resonate at higher frequencies, and softer materials will resonate at lower frequencies. Resonance will therefore reinforce particular overtones in the vibrating string, while cancelling out others. Woods are not uniformly dense, so each has a complex sonic "signature" of resonant frequencies.
Guitars made of synthetic materials, like Steinbergers, have great sustain because they don't resonate a lot, which can rob the string of its energy. They have a bright, clear tone, which some people feel is "cold" sounding.
Wooden guitars are preferred by most players because they have "warmth" and character that is more pleasing to the human ear than the full sonic frequency range of the pure vibrating string. This "warmth" comes from a subtle rolling-off of some of the harsher high frequencies and the emphasis of lower-midrange.