to join two things into one: to fasten objects together, or to bind oneself to others in alliance or company
At its core this word means making two separate things into one. In the instructions for building the tabernacle it is the ordinary word for coupling: curtains fastened edge to edge, shoulder pieces sewn into a single garment, so that many parts hold together as one whole. The prophet Ezekiel uses it the same way for living creatures whose wings touch wing to wing.
The same idea carries over to people. When kings pool their armies, when a king of Judah goes into partnership with a neighboring king, when two royal houses seal a treaty, or when a nation attaches itself to its idols, this is the word. The thing being joined is no longer two independent parties but a single bonded unit, which is why the word can carry a warning: to join yourself to the wrong ally or the wrong god is to be tied to its fate.
Because the picture is fastening rather than merely gathering, English translators reach for different words depending on what is being joined: couple, join, ally, keep company, attach. They are all the same underlying act of binding two into one.