What is the definition of a molecule?
A chemical species comprising 2 or more atoms linked by chemical bonds, and which is electrically neutral.
Molecules can comprise two or more identical atoms, or two or more different atoms. The key points in determining whether a species is a molecule, however, are (a) the atoms must be linked together by chemical bonds, and (b) overall there is no formal charge. There may well be charge inequality due to electronegativity differences between different atoms (i.e. partial positive charge on one atom, partial negative charge on the other) but overall a molecule is electrically neutral.
This is in contrast to atoms that are ionically bonded, whereby the compound exists as pairs of charged species, e.g. NaCl. Such compounds are not composed of molecules, but of ions.