Why do halogens tend to form diatomic molecules?

Through reacting with the other atom by sharing one electron