With cuttings, it’s easier to graft two plants within the same family (not always possible, but easier than gross breeding them). Tomatoes and Jimson weed are both in the Solanaceae family, so they share a fairly close gene line, which makes them more compatible graft wise (they also lack woody stems which makes it a bit easier).
With tomatoes on jimson weed, the jimson weed is used as the rootstock, and the tomato tops are grafted onto them. The jimsonweed is toxic, leaves, roots, flowers, fruits, so whatever alkaloids the stems and roots produce end up getting transferred to the tomato plant tops (through normal transporting of nutrients through the veins). It’s a similar principle to how systemic pesticides work.
A similar thing is dwarf citrus varieties. Growers graft varieties of other citruses onto the rootstock of Poncirus trifoliata, which never grows higher than 25 feet. This habit gets transferred into the scionwood (the tops that grow and produce fruit), keeping them small.