Yes, the same building blocks can make very different drugs. Much like a pile of lumber can look alike, but you might build many different styles of house from the same basic lumber, ranch, 2 story, modern, federal, etc. Often a single atom or a few can change major properties of a molecule, which is why drug discovery is not so easy, sometimes a small change will have huge, and unpredictable effects on its activity or metabolism.
Conversely, there are some drugs that look very different, but act similarly in the body or in other ways, ie morphine and fentanyl, benzene and thiophene, ethanol and valium.