Most devout Jews, Christians, and Muslims believe that Moses wrote whole the Torah, including Genesis. Genesis takes place over 200 years before Moses’ birth. so how did he do it? It seems to me that he likely had the help of written records left behind by Joseph. Joseph was made vizier of Egypt at 30 and lived 80 more years, so he likely learned to write in Egypt or had access to scribes since he was a political figure. Then Moses who was raised in Pharaoh’s house for 40 years, would have learned to read and write in Egyptian and had access to Joseph’s writings.
Joseph must be the main source for what Moses wrote in Genesis because there are 12 chapters dedicated to Joseph, but only about 9 chapters for Jacob, and only about 6-7 dedicated to Isaac. Abraham has 13 chapters focused on him, but he is the beginning of the covenant of Israel, so of course, he gets the most attention. However, Genesis ends with Joseph and not with someone else between him and Moses. There are 144 years between Joseph’s death at 110 and the Exodus story when Moses is 80 years old, so Genesis could have continued up until Moses’s birth but it stops specifically at Joseph’s death and Exodus picks up at Moses’ birth 64 years later.
When one reads Genealogy chapters like chapters Genesis 5, 11, and 36, they are written like an index which implies Moses has his own “Wikipedia” via a scroll of the lineages. These passages are lists of toledoth (תּוֹלְדֹת) which is Hebrew for “generations” or “descendants”. There may have also been some tablets preserved from before Joseph’s time preserved in cuneiform, that Joseph used to get the genealogies and such going back to the time Abram meeting Melchizedek (the high priest of God at that time). Being the high priest of God, Melchizedek would have had access to the history of the world and all creation up until that time from God directly. He knew God and was able to operate as a priest to God in the midst of nations with different religions, so it seems reasonable that he would have had records of the history from Noah to Abram and everything before that.
In Genesis chapter 41 Joseph is reunited with the brothers who sold him into slavery and is pretending he doesn’t recognize them. They don’t recognize him because he is the Vizier of Egypt and his official name is Zaphenath-paneah. In the process of scaring them by accusing them of beings spies (a trick to get them to bring the whole family to Egypt), they are freaking out when he puts them in prison. They complain to each other that they deserve this and this is punishment for selling Joseph 22 years ago. However, they didn’t realize that Joseph understood them because as the vizier of Egypt, he was using an interpreter for them because they were foreigners. Joseph was using an interpreter unnecessarily since he is bilingual (speaking Hebrew and Egyptian) at this point which gives credence to the idea that he wrote the patriarch narratives before Moses in the Egyptian language. Then Moses who was raised in Pharaoh’s house would have grown up learning Egyptian, as well as the Hebrew language since his own mother was his nanny. Also later while he spent 40 years in Midian he may have learned the Proto-Sinaitic script from the Midianites, which is the first version of the alphabet that Semitic languages like Hebrew, Aramaic, Arabic, etc use. This script is said to have started from a simplification of the Egyptian writing system, so it’s also possible that Joseph or Moses, or someone else from the region invented it. This means that Moses was literate in two languages, knowing both Egyptian and Proto-Sinaitic and this would have allowed him to translate the creation story and patriarch histories from Joseph’s Egyptian scripts to the Torah’s version of Genesis in a Semitic language during the post-Exodus wilderness journey. I have an article on author ship in the bible that goes more into general ideas surrounding construction here.