Halachos are spread throughout the Torah. Many times the Gemara uses pesukim that are scattered all around to figure out the true application of pesukim. So if, for example, we only had the section about topic X that was discussed in one place, we wouldn't have the correct picture because we need to take into account things said in another place. Also, the Torah tells us that Moshe said "These words" to the Jews--thus implying that those were the actual words he taught.
My question is that in the Torah it seems like some of the halachik sections are very separate from each other. For example, things that were given in Egypt. There are several sections about the moadim. A whole bunch of halachos are taught in Devarim right before entering Eretz Yisrael.
How did they learn the correct halacha before they had all the pieces of the puzzle?