Right after it says all the different parts of the world and sky being created on six separate days and rest on the seventh, it says, "These are the generations of the heavens and the earth when they were created, on the day that the Lord God made earth and heaven." And it goes on to say that there was nothing on the ground, then God formed water, then Man, then Eden, then plants, then animals, seemingly in that order all on one day. So I'm not sure I understand, in which order did these things actually form and on what day(s)? The best I can think of is that the potential for everything was made on the first week and then on the eighth day that's when they were actually made (and in a different order) but that doesn't feel right.
Rashi comments on the spot that the "one day" refers to the first day. This might refer to something very basic, such as all matter.
Later on commentaries say that the potential was created during 6 days as we read in first chapter, then it was realized with help of man's prayer in the order we read in the second chapter - but only after man arrived.
The beginning of Bereishis is connected to what Chazal called M'aseh Bereishis, which are secret esoteric teachings about the nature of the world. Thus the literal meaning of these pesukim is not the primary one, so apparent contradictions on the literal level are not such a problem. The deeper meaning of each part can be referring to two different things, or to a truth which may only come through by comparing the two parts.
Even on the literal level, the apparent contradictions can be explained. The Torah starts off: "In the beginning God created the heaven and the earth" which sounds like they were created on the first day. It then describes further details and developments over the following days. In the second chapter, it mentions how heaven and earth were created in a day, and then it immediately jumps to man, the focus of this part. So there isn't really a contradiction on number of days.
Many interpretations have been offered to the meaning of these two stories about the creation of man. For example, Rav J.B. Soloveitchik wrote The Lonely Man of Faith as an explanation of these two passages. He says the first passage refers to "majestic man" where man is master of nature, while the second passage refers to man in a different role, as "covenantal man" who submits to God's will.
While R.J.B. Soloveitchik is not trying to explain historical events, one can give such an answer also. The first story of creation can be referring to the ancestor of mankind, while the second story can be a later event referring to the ancestor of a specific group of people. An approach like this could also be used to explain why humans have been around for more than 6000 years, as asked in this question.