Here are some of the factors that affect tone, more or less in order of how they influence the sound and timber of a guitar.
Design: Not all electric guitars are built as “slabs of wood with strings and pickups screwed to them.” That pretty well describes most solid body guitars, but there are also hollow body guitars (used mostly for jazz) and semiacoustic models that fall somewhere in between.
Hollow body guitars are pretty much like acoustic guitars with pickups and have a more rounded attack. Semiacoustics are like thin hollowbody guitars with extra reinforcement and sound like Chuck Berry (or Ted Nugent.) Solid body guitars have a sharper attack and the notes tend to sustain longer (Supposedly, one design criteria for the original Gibson Les Pauls was that a plucked string had to stay audible for at least twenty seconds.)
Wood: One of the original boutique guitar builders made the claim that all guitars are acoustic guitars, and even without an amp the difference in tone between, say, a Fender Stratocaster and a Gibson SG is obvious.
Wood affects tone in a similar way to guitar design. Softer woods absorb higher frequencies and provide less sustain than harder woods. For example, the maple top on a Les Paul provides a warmer sound than a Les Paul Jr.–roughly the same guitar without the maple top.
Strangely, wood selection in basses may work in the opposite direction. Softer woods tend to dampen the attack at the start of a note, giving what seems to be greater sustain.
Pickups: Pickups have about as much of an affect on tone as design and the type of wood. Pickup design affects both the pickup’s tone and how much of the string’s length is “picked up.”
There are two basic pickup designs, single coil and dual coil “humbuckers.” Traditionally, single coil pickups tended to be brighter while humbuckers tended to have less background noise. Humbuckers and single coil pickups with wider windings pick up sound from a longer section of the string; they may pick up more harmonic content but the string harmonics may also cancel out. Beyond that, the same pickup will deliver a deeper tone when closer to the neck and away from the bridge.
Electronics: Beyond pickups, electronics make a difference. Sure, there are guitars with active electronics and some made to hook up to synthesisers, but even the components used in passive wiring can affect tone. Capacitor ratings for tone controls affect frequency rolloff; the quality of the components affects how noisy the guitar is, and with the weak signal given by the pickups, I assume that even the type of wire used might make a difference (Please note: I am NOT talking Monster Cable stuff here; I’m talking about the difference between printed circuit boards and 16-18 gauge wire.)
Beyond that (FINALLY!), the quality of the guitar makes a world of difference. Sure, more money can be spent on paint, inlay work or whatever looks good, but it takes a lot to make a guitar that just plays good. A guitar with the strings just a few millimeters above the frets will be a lot easier to play than one with the strings a quarter inch above the frets. There are other factors as well, and what makes someone want to play a particular guitar sometimes just can’t be quantified. Luthier work is an art as well as a science.
Finally, names and reputations matter. Someone might buy a $6,000 Taylor acoustic when they couldn’t tell the difference between it and a Yamaha. The same thing happens with electrics.