This is a case of competition for an electron. Chlorine by itself really "wants" another electron. When it faces another chlorine with the same "desire", neither wins, but both benefit some by sharing so we see Cl2. However, chlorine wins that battle, hands-down, when fighting sodium. The second chlorine from Cl2 is left out on its own and has to go find its own electron somewhere else.
If you have metal Na, and you place it in Cl2 gas, there will be an instant where Cl2 collides with Na and makes a "NaCl2" but that reacts immediately and is gone. It is simply so unstable that it does not exist except instantaneously. You end up with NaCl, Cl (unpaired and unionized) and a lot of heat. that lone Cl will wander around until it collides with something that will happily give or share an electron. That tends to also happen pretty quickly.
The second electron that sodium could give is not one that sodium will give up easily, so it doesn't, and so we don't get NaCl2 (Na2+ + 2 Cl-). There are some anions that can act as pairs (like S2 acting like S2 (2-) instead of 2 S2-, but those are also not generally favored for similar reasons. the S2 (2-) anion is only stable in a very narrow window of conditions. So we can get things like pyrite (FeS2) rather than pyrrhotite (FeS) but you won't see that with chlorine. Chlorine is just too powerful an electron attractor.
It is an energy stability thing.