A couple of other interrelated perspectives are presented below.
The first perspective comes from the article Artificial Intelligence, Logic of Discovery and Scientific Realism (Alai), where they state, using scientific discovery as an example (as per the example in the question), that
if the process of
discovery is rational, mustn’t it therefore follow rational criteria and rules, hence a
logic? On the other hand, it is well known that chance, luck, and insight often play an
important role in discovery.
Effectively, almost like a case of someone 'tripping over' the final piece of their theorem. The author goes further, contending that if their were a rational set of steps, thus
if
discovery were just a matter of rule following, why couldn’t anyone learn the necessary rules and become a great scientist? Or why couldn’t the scientists themselves just follow
the logic of discovery and program in advance new discoveries, and rapidly achieve
such results as a cure for cancer, or the cold fusion of atom, which while sorely needed
still elude the efforts of researchers?
Meaning, according to this article's perspective, that luck, chance and insight play a major role.
The final factor, insight, is alluded to in the website Einstein's Pathway to Special Relativity (Norton), taking the example scientist from the question, Albert Einstein and how he developed, for example, the Theory of Special Relativity, which started when
he began to think about ether, electricity, magnetism and motion.
Essentially, he had insight by
pondering these developments that led Einstein to discover the
special theory of relativity in 1905.
A key point made is that
The discovery was not momentary.
This is crucial, the ideas didn't just 'pop' into his head, the theory was the outcome of having learned and developed an insight in the background information, latest developments in relevant disciplines and of course,
in Einstein's own reckoning, seven and
more years of work.
As an independent researcher, (and I am not comparing myself to Albert Einstein), the discoveries that I have found, have had successfully peer reviewed and have been published come from having some specific insight, through background reading, training, education etc, to topics and skills required relevant to the discovery, as well as a lot of work to bring these insights together with new observations to make a discovery.