What is the relationship between diatomic molecules and diatomic elements?

Diatomic are a subgroup of diatomic molecules.

Every molecule that consists of two atoms is diatomic. Only if the two atoms are the same there is a diatomic element.

So ##O_2## is a diatomic element (and thus a diatomic molecule) ##HCl## is a diatomic molecule, but not a diatomic element.