The story is a mish mash of Mesopotamian stories. In one story Adamu (Adam) is offered immortality by the sky gods but the god of the world Enki told him that if he ate the food offered it would kill him. Enki was a trickster god but also a god of wisdom and many scholars believe the story was telling how the god Enki did not want man to have immortality so he would not be like the gods. In the Gilgamesh story he retrieved a plant from a lake that would make him immortal but he took a nap first and a snake came along and ate it instead. Because a snake sheds its skin it’s has been associated with immortality.
In Genesis god creates Eve using a rib from Adam , in another story from Mesopotamia Enki gets healed by a female goddess which has something to do with his rib can’t remember the details but she becomes associated with a rib.
The tree of knowledge is all over the place in Mesopotamian stories. So is stories about Eden. The serpent in the story is probably not a Satan or a devil but a serpent god Ningizzida.
The writer of these stories in genesis clearly got a lot of details wrong in his attempt to put several stories in to one.