Why 18 minutes (or other minhagim). Where did these numbers come from?
There's an article on the subject at Hirhurim, by Rabbi Ari Enkin. He cites two reasons that are given for the 18-minute figure:
It's based on a Gemara in Shabbos (35b), where it says that six shofar blasts were blown to announce that Shabbos will be starting soon; the third one is the signal for lighting candles, then "he waits as much time as it takes to roast a small fish," blows the last three blasts, and Shabbos begins. This amount of time is elsewhere stated to be 18 minutes.
It's in deference to the opinion of Sefer Yereim (by R' Eliezer of Metz, one of the Tosafists), who says that the halachic day ends (and thus Shabbos begins) a 1-mil walk before sunset. There are various opinions as to how long a 1-mil walk is, ranging from 18-24 minutes, but 18 minutes is the most widespread (in connection with other laws such as the amount of time that it takes for dough to become chametz), and therefore it was adopted here too.