There are many myths across many cultures about how eclipses occur.
In Rigveda (5-40-5 to 9), seer Atri explained scientifically why eclipse occurs.
Puranas have described the story of Rahu, Ketu (North Node and South Node of Moon) in a mystical way.
But the essence remains same as in Rig Veda, which was composed more than 23,000 years ago.
यत तवा सूर्य सवर्भानुस तमसाविध्यद आसुरः |
अक्षेत्रविद यथा मुग्धो भुवनान्य अदीधयुः ||
सवर्भानोर अध यद इन्द्र माया अवो दिवो वर्तमाना अवाहन |
गूळ्हं सूर्यं तमसापव्रतेन तुरीयेण बरह्मणाविन्दद अत्रिः ||
मा माम इमं तव सन्तम अत्र इरस्या दरुग्धो भियसा नि गारीत |
तवम मित्रो असि सत्यराधास तौ मेहावतं वरुणश च राजा ||
गराव्णो बरह्मा युयुजानः सपर्यन कीरिणा देवान नमसोपशिक्षन |
अत्रिः सूर्यस्य दिवि चक्षुर आधात सवर्भानोर अप माया अघुक्षत ||
यं वै सूर्यं सवर्भानुस तमसाविध्यद आसुरः |
अत्रयस तम अन्व अविन्दन नह्य अन्ये अशक्नुवन ||
The sage here described how Svarbhanu created eclipses of Sun and Moon and how Sun appeared after eclipse in sky.
Svarbhanu is Sva + Bha+ Anu. Sva means sky. Bha means light. Anu means follower.
Follower of light is shadow, which is present in the sky.
Eclipse is seen due to this shadow. It is a miracle or phenomenon and Asura means the same (not demon).
Stephen Hawking states that, according to Viking mythology, eclipses occur when two wolves, Skoll and Hati, catch the sun or moon.
At the onset of an eclipse people would make lots of noise, hoping to scare the wolves away.
After some time, people must have noticed that the eclipses ended regardless of whether they ran around banging on pots.