Are compounds formed when atoms of two different elements join together?

Yes, two or more different atoms of two or more different elements will, when chemically bonded, make a chemical compound.