The story
From the notion that if two sides of the same blade are sharp, it cuts both ways. The metaphor may have originated from the Arabic expression سَيْفٌ ذُو حَدَّيْنِ (sayfun ḏū ḥaddayni, “double-edged sword”) or from the Hebrew expression חֶרֶב פִּיפִיּוֹת (ẖérev pifiyót, “double-mouthed sword”). The metaphor is first attested in English in the 15th century.
Etymology from Wiktionary, CC BY-SA 4.0.