This is a bit complicated. The main theory on the creation of the Torah or Pentateuch is the Documentary Hypothesis. Basically, it is thought that these first five books are a combination of 4 sources and possibly a 5th editor. The sources are J, E, P, and R. J is the Jehovah source (they used the term Yahweh for God. Jehovah is the transliteration of the term to German, and then English speakers, not realizing how it should be pronounced based on the German language, bastardized it). E is the Elohim source as he called God Elohim. P is the priestly source as they were most like a priest and were more concerned about that aspect. R is the redactor who edited the works together and added a bit as well. There may be another editor as well who cleaned it up.
These sources can be picked out quite well, and it explains why there are multiple tellings of the same stories.
These sources would have been known early on, especially as some were based in specific geographic areas. J and E, for instance, were most likely court writers, one for the northern kingdom and the other for the southern kingdom.
These works would have circulated independently for decades if not centuries. It wouldn’t be until much later that the Torah, as we know it, was compiled. And even then, it wasn’t attributed to Moses. That occurred more towards the end of the Babylonian captivity, when they were regrouping and were looking at their cultural heroes.
While Moses would largely then be attributed as the author, there were scholars who rejected that notion. But when modern Biblical scholarship began in the 1800s, the idea that Moses was the author had been ignored and the Documentary Hypothesis came out.
The authorship of the Pentateuch is definitely a question for /r/AcademicalBiblical or /r/AskBibleScholars. Hopefully one of their experts will swing by here.
Spinoza (17th century) categorically rejects Moses as the author of the Pentateuch. He quotes an earlier Rabbi, Ibn Ezra, and believes that Ibn Ezra also believed that some sections could not have been written by Moses. Here's a quote from Spinoza (you can read it here if you want)
(10) The words of Aben Ezra which occur in his commentary on Deuteronomy are as follows: "Beyond Jordan, &c. . . . If so be that thou understandest the mystery of the twelve . . . moreover Moses wrote the law . . . The Canaanite was then in the land . . . . it shall be revealed on the mount of God . . . . then also behold his bed, his iron bed, then shalt thou know the truth." (11) In these few words he hints, and also shows that it was not Moses who wrote the Pentateuch, but someone who lived long after him, and further, that the book which Moses wrote was something different from any now extant.
(12) To prove this, I say, he draws attention to the facts:
(13) 1. That the preface to Deuteronomy could not have been written by Moses, inasmuch as he ad never crossed the Jordan.
(14) II. That the whole book of Moses was written at full length on the circumference of a single altar (Deut. xxvii, and Josh. viii:37), which altar, according to the Rabbis, consisted of only twelve stones: therefore the book of Moses must have been of far less extent than the Pentateuch. (15) This is what our author means, I think, by the mystery of the twelve, unless he is referring to the twelve curses contained in the chapter of Deuteronomy above cited, which he thought could not have been contained in the law, because Moses bade the Levites read them after the recital of the law, and so bind the people to its observance. (16) Or again, he may have had in his mind the last chapter of Deuteronomy which treats of the death of Moses, and which contains twelve verses. (17) But there is no need to dwell further on these and similar conjectures.
(18) III. That in Deut. xxxi:9, the expression occurs, "and Moses wrote the law:" words that cannot be ascribed to Moses, but must be those of some other writer narrating the deeds and writings of Moses.
(19) IV. That in Genesis xii:6, the historian, after narrating that Abraham journeyed through the and of Canaan, adds, "and the Canaanite was then in the land," thus clearly excluding the time at which he wrote. (20) So that this passage must have been written after the death of Moses, when the Canaanites had been driven out, and no longer possessed the land.
If you want to go back even further. The Talmud, in Bava Batra 15a records that Rav, who probably lived in the 3rd century, states that Joshua wrote the last 8 verses. So you can see that there was some pushback from even the earliest times.