<PERSON> probably took the twenty-four years from the 1587 work Historia von D. Johann Fausten, commonly called the Faustbuch. This was published in Frankfurt, in the German language, and frequently reprinted. It was translated into English as The Historiye of The Damnable Life and deserued Death of Doctor Iohn Faustus in 1592, a text now lost, although we do have later versions than those that might have been available to <PERSON>.
In the 1618 version of the English text, chapter 6, <PERSON> promises as follows:
at the end of 24. yeares next ensuing the date of this present letter, they being expired and I in the meane time, during the said yeares be serued of them at my will, they accomplishing my desires to the full in all points as we are agréed: that then I giue them all power to doe with me at their pleasure, to rule, to send, fetch, or carry me or mine, be it either body, soule, flesh, blood, or goods, into their habitation, be it wheresoeuer: and hereupon, I defie God and his <PERSON>, all the hoast of Heauen, and all liuing creatures that beare the shape of God, yea all that liues: and againe I say it, and it shall be so.
The text is clearly similar to <PERSON>'s version of the pact, which also mentions "full power to fetch and carry the said <PERSON>, body and soul, flesh, blood, or goods, into their habitation". This compares to the German original:
daß so 24. Jahr, von Dato diß Brieffs an, herumb und füruber gelauffen, er mit mir nach seiner Art und weiß, seines Gefallens, zuschalten, walten, regieren, führen, gut macht haben solle, mit allem, es sey Leib, Seel, Fleisch, Blut und gut, und das in sein Ewigkeit. Hierauff absage ich allendenen, so da leben, allem Himmlischen Heer, und allen Menschen, und das muß seyn.
Both texts then go to a year-by-year narrative of <PERSON>'s adventures. At the seventeenth year, he signs a further letter acknowledging that there are only seven to go. In his final speech he mentions the twenty-four years several times, saying:
I haue promised vnto him at the end and accomplishing of 24. 351
yeares, both body and soule, to doe therewith at his pleasure: and this day, this dismall day, those 24. yeares are fully expired, for night beginning, my houre-glasse is at an end
This is all to say that <PERSON>'s primary source repeatedly mentions this specific term. The <PERSON>'s origins are obscure but it may draw on the <PERSON> bedencken of <PERSON> (writing under the name <PERSON>), a contemporaneous work on the topic of witchcraft. There is a later edition in 1597 that responds to the <PERSON> and says it introduced errors into the story! The 1585 text does mention a pact of twenty-four years, though, and a separate passage narrates the re-making of the agreement (which the <PERSON> puts in year 17 specifically).
<PERSON>'s text relates the <PERSON> legend to witchcraft and witch-trials in general. In that line, the general idea of making a pact with the devil is well-known. The notion of a fixed term is probably because in the theory of dealing with demons, you are meant to specify a length of time that the demon will be bound (and in general you are supposed to be very precise about all the contractual terms). Moreover, immortality may not be within <PERSON>'s power to give. So the metaphysics of the situation demand that <PERSON>'s soul be forfeit after some finite amount of time, although there is nothing in the broad background to say why 24 years might be a special number.
One theory from <PERSON> demands a little more calculation (in his introduction to <PERSON> Faustus and the Censor, 1987). The supposed historical <PERSON> died in 1541. Twenty-four years before that is 1517. A very notable event of 1517 is that on 31 October, All Hallows Eve, <PERSON> nailed up his Ninety-Five Theses on his church door in Wittenberg. 321