He definitely used his own experiences with epilepsy and pre-epileptic visions when writing
The Idiot, but that was much later. I think
The Double had more purely literary antecedents. Doppelgängers were an established trope by then, which Dostoevsky got from the German romantics—people like E.T.A. Hoffmann, who specialized in stories with weird phenomena that
could have a natural explanation (e.g. the mentally ill hero's delusional imagination) but are uncanny and probably magical all the same.
The Double was only Dostoevsky's second novel but it was one of the best things he ever wrote. It's fabulous! And short.