Narcissism is a clinical term built on a very old story, and the two were joined by a doctor only in the 1890s.
The myth is best known from Ovid's Metamorphoses. Narcissus is a beautiful young man who rejects the nymph Echo, falls in love with his own reflection in a spring, and wastes away beside it. His body turns into the flower that carries his name. Other versions differ on the details. One summary says he rejected either Echo or a young man named Ameinias, and the gods punished him for it.
English long used the name as a symbol before it had a word for the condition. By 1767 "Narcissus" was already being used for a person in love with himself, and Etymonline notes that Coleridge used the word in a letter in 1822.
The scientific word came later. The German psychiatrist Paul Näcke published Narzissismus in 1899, in a work on sexual perversions. According to Etymonline, the comparison had been suggested the year before by the British writer Havelock Ellis. In a short 1927 paper Ellis argued that the credit should be shared with Näcke. One Wikipedia article gives 1889 for both men, but Etymonline and Wikipedia's history article agree on 1898 and 1899, so 1889 looks like a typo.
The word moved from sexology into wider psychology. Otto Rank wrote the first clinical paper on narcissism in 1911, and in 1914 Sigmund Freud published "On Narcissism: An Introduction." English dictionaries record narcissism from 1905, narcissistic from 1912 and narcissist from 1919. Narcissistic personality disorder was added to the DSM-III in 1980.
The flower is odder than it looks. Etymonline says the plant name narcissus may originally have meant an iris or lily. An old folk etymology links it to Greek narke, "numbness," because the plant's alkaloids are sedative. The linguist Beekes rejected that link and called the name Pre-Greek.
So the personality trait is named for a boy, and the boy is named for a flower whose name may not even be Greek.