If two atoms of different elements combine it is both a molecule and a compound.
H2O (water) is a compound as it contains both hydrogen and oxygen. All compounds (a mixture of elements) are molecules but not all molecules (of the same elements) are compounds.