I stumbled upon the very interesting concept of cryptomnesia.
Cryptomnesia, or inadvertent plagiarism, is a memory bias whereby a person falsely recalls generating a thought, an idea, a song, or a joke, when the thought was actually generated by someone else. In these cases, the person is not deliberately engaging in plagiarism, but is rather experiencing a memory as if it were a new inspiration.
Man and His Symbols (1964) by Carl Jung
The term cryptomnesia was first put forward by Carl Jung as concealed recollection in Man and His Symbols.
As explained expertly by Carl Jung, in Man and His Symbols,
“An author may be writing steadily to a preconceived plan, working out an argument or developing the line of a story, when he suddenly runs off at a tangent. Perhaps a fresh idea has occurred to him, or a different image, or a whole new sub-plot. If you ask him what prompted the digression, he will not be able to tell you. He may not even have noticed the change, though he has now produced material that is entirely fresh and apparently unknown to him before. Yet it can sometimes be shown convincingly that what he has written bears a striking similarity to the work of another author–a work that he believes he has never seen.”
Blind Pew by N. C. Wyeth
Robert Louis Stevenson refers to an incident of cryptomnesia that took place during the writing of Treasure Island, and that he discovered to his embarrassment several years afterward:
I am now upon a painful chapter. No doubt the parrot once belonged to Robinson Crusoe. No doubt the skeleton is conveyed from Poe. I think little of these, they are trifles and details; and no man can hope to have a monopoly of skeletons or make a corner in talking birds. The stockade, I am told, is from Masterman Ready. It may be, I care not a jot. These useful writers had fulfilled the poet’s saying: departing, they had left behind them Footprints on the sands of time, Footprints which perhaps another — and I was the other! It is my debt to Washington Irving that exercises my conscience, and justly so, for I believe plagiarism was rarely carried farther. I chanced to pick up the Tales of a Traveller some years ago with a view to an anthology of prose narrative, and the book flew up and struck me: Billy Bones, his chest, the company in the parlour, the whole inner spirit, and a good deal of the material detail of my first chapters — all were there, all were the property of Washington Irving. But I had no guess of it then as I sat writing by the fireside, in what seemed the spring-tides of a somewhat pedestrian inspiration; nor yet day by day, after lunch, as I read aloud my morning’s work to the family. It seemed to me original as sin; it seemed to belong to me like my right eye. —The Art of Writing
See also rediscovery, déjà vu, memory failure, false memory syndrome, confabulation, automatic writing, memory bias, memoir