Well, it’s myth. It’s a poetic musing from the Bronze Age and never meant to be a scientific truth. So, It can be poetically “true” or allegorical while also being scientifically false.
it’s also true that this religious musing is not original to the Torah, but the creative yearnings of emerging Jewish priestly scribes breaking from the polytheistic religions of earlier agrarian Sumerian beliefs to establish their own ethnic nomadic Shepherding peoples.
The Priestly scholars of ancient Judaism were fashioning their own ethnic-based belief system and Iron Age religion in rebellion with Earlier Sumerian Sea Serpent Goddesses of Mesopotamia, Assyria, Hittite, and Babylonia. (See Semitic Mythology. The Mythology of All Races Stephen Herbert Langdon). This was a common Iron Age literary trend, as Thor battles the Midgard Serpent, and Zeus defeats the ferocious serpent Typhon.
When nascent Judaism began and broke away from polytheistic traditions they adopted the Midianite Warrior Volcano God Yhvh or Yahweh as the reigning deity above all the earlier Jewish deities. (See Theophilius James Meek Hebrew Origins)
The Jewish Scholarly Priests rewrote the early Sumerian Creation stories featuring the Serpent Goddess Tiamat and her ferocious sea serpent side kicks Tohu and Bohu.
In their adaptation of the Genesis creation story (and later redacted) they refer to Yahweh slaying The Goddesses of the Abyss Tohu and Bohu and Leviathan who then fashioned the universe from their dead carcasses. (See Robert Price: Treatises on Genesis)
As an utter rejection of their Babylonian Exile, the authors of the new Yahweh cult had to demonize the previous Sumerian goddess Tiamat and her vicious serpent consorts and contrive to crown Yahweh as their own badass Serpent-slaying godhead and unite the Jewish Tribes under one deity as His Chosen Ones to rebuild the nation of Israel. (See B. Lang The Hebrew God, Portrait of an Ancient Deity).
Postscript: The ancient Sumerians believed the early cosmos was a vast sea of chaos ruled by the goddess of the salt sea Tiamat. The etymology goes something like this: Tehom, Tohu, Tahamat, Tiamat
Genesis 1:2 and 8:2 make TEHOM "the deep"; but this is clearly a late emendation of the original story; for details see TANINIM, but especially the textual commentary on Genesis 1:1-2:3.
The Bible uses TEHOM poetically to mean the seas, or a gulf, or an abyss; but it also uses TOHU in the same verses to mean the void of uncreation, the darkness before creation. Tehom is the Yehudit form of Tahamat or Tiamat, the primal sea-serpent of original Creation; we can assume that TOHU is the same or at least an alternative variation.
Of course, this is more the domain of mythology and theology than logic. The logic of the ancient mind was that even a God could not create something from nothing. While this idea would become a principle of the Catholic Church later on (Creatio ex nihilo) it was inconceivable to more primitive religions.