All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The Hadeeth narrated by Ibn Mas’ood was reported in different wordings, among which is the Hadeeth reported by Al-Bukhari with the wording mentioned in the question. There is also the Hadeeth reported by Muslim in his Saheeh with the following wording: “One of you (i.e. the human being) is put together in the womb of his mother for forty days, then he becomes in that (period) a clinging clot in a like period of time, then he becomes in that (period) a little lump of flesh in a like period of time, then an angel is sent to him who breathes life into him, and he (the angel) is commanded to record four things: his provision, his age, his deeds (good or bad), and whether he is to be wretched or prosperous.” [Muslim]
The scholars differed in opinion about the meaning of the Hadeeth and in determining the duration (stage) of a sperm drop, a clinging clot, and a lump of flesh, whether it is forty days for each of them or forty days for all of them. The first interpretation is the one that confused the questioner in relation to what has been recently discovered. But the strongest opinion about the meaning of the Hadeeth is the second interpretation: that the stages of a sperm drop, a clinging clot, and a lump of flesh are all in the first forty days of pregnancy, and that the formation of the fetus as a human being is in the second forty days of pregnancy. What proves this is the Hadeeth narrated by Huthayfah ibn Aseed Al-Ghifaari that he heard the Prophet saying: “When 42 nights have passed for (the stage of) the sperm, Allaah sends an angel who would shape it [in human form] and would create its hearing, its sight, its skin, its flesh and its bones, and then the angel would say: “O Lord, is it a male or female?” So, your Lord decrees whatever He wishes and the angel writes it down, and then the angel says: “O Lord, what about his age?” So, your Lord says whatever He wills and the angel writes it down, and then the angel says: “O Lord, what about his sustenance?” So, your Lord decrees whatever He wishes and the angel writes it down, then the angel comes out with the record of destiny in his hand and the angel will not do anything more or less than what it is commanded.” [Muslim]
Shaykh Abdul Majeed Az-Zindaani has dealt with this subject in detail in his research: ‘Embryology in the light of the Quran and the Sunnah’, which he presented in the First International Conference on Scientific Miracle of the Quran and Sunnah. So you may refer to this research for more details.
Allaah Knows best.