Attach comes from Old French atachier ('to fasten to a stake'), derived from Frankish *stakka ('stake'), and entered English in the fourteenth century with both physical and legal senses.
To fasten or join one thing to another; to attribute importance or significance to; in law, to seize property or a person by legal authority.
From Old French atachier ('to fasten, fix, attach'), a variant of estachier ('to fasten with a stake'), from estache ('a stake, post'), which derives from Frankish *stakka ('stake, stick') or a related Germanic form. The word's history centres on the physical act of fastening something to a stake or post. Anglo-Norman legal language gave it a judicial meaning: to 'attach' someone was to arrest them, to fix them in place by legal authority. English adopted both senses in the fourteenth century. The emotional sense ('attached to someone') appeared by the seventeenth century, and the modern digital
The words 'attach' and 'attack' are siblings from the same root. Both derive from Old French forms meaning 'to fasten to a stake'. 'Attach' kept the peaceful sense of fastening; 'attack' took the hostile sense of staking or pinning down an enemy. Italian attaccare preserves both meanings in one word.