Why would two atoms form a covalent bond instead of an ionic bond?

Both atoms in a bond have similar electronegativity; thus, neither atom is willing to transfer their electrons. Instead, the atoms both share electrons to satisfy the octet rule.
Both atoms of the bond are metals, so neither can transfer electrons. Instead, the atoms share valence electrons in a free-moving sea of electrons.
One atom is a metal and the other a nonmetal, meaning there is a difference in electronegativity; thus, the atoms will transfer electrons. Each atom forms an ion to satisfy the octet rule.
The type of bond that is formed is based on the amount of energy that is supplied to excite the valence electrons. Thus, it would depend on the environment, not the atoms, involved.

2 answers

almost to the point. All bonds are to somewhat ionic or covalent. You are correct it depends on energy. Electronegativity is the difference in energy of attraction...see this chart.
https://www.google.com/url?sa=i&url=https%3A%2F%2Fdashboard.dublinschools.net%2Flessons%2F%3Fid%3Db14447368ffc26edfe0f1f8ebf045cd2%26v%3D1&psig=AOvVaw3rcpAZq7aQAr6SzHTxnRrd&ust=1573602982365000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCMD175mu4-UCFQAAAAAdAAAAABAD
Would it be D then?