It is extracted from tobacco, although many plants contain nicotine including tomatoes.
Yes, it can be built in the lab from other chemicals, however, there exists a concept in chemistry called chirality. Look at your hands. Are they pretty much exactly the same structure? Kind of, yet they are exactly backward from each other.
If you place a palm over the back of the other hand, thumbs stick out in different directions. This is chirality: the same structure, yet molecular mirror images of one another.
In fact, lab produced nicotine and nicotine produced in plants are the same molecule, but exactly backward.
Thus the lab produced stuff doesn't work in the body like the plant produced nic.
And that's probably MUCH more than you ever wanted to know on this subject.