Each peerage has its own letters patent which sets our what happens to the title. The most common arrangement is that it is "with remainder to heirs male of the body" which means that it passes to legitimate natural (ie not adopted) men. But you can have "heirs of the body", and many other variations. In this case the Dukedom has been granted without any remainder, which means that no one inherits it when the current holder dies and it reverts to the Crown. I imagine that Edward will outlive his older brother given their age gap. Which means that it will probably be William's to give away in the future.
Separately, they are starting to run out of traditional Royal Dukedom titles to give away. They've potentially only got York, Edinburgh and Cambridge left for future use, unless they want to be more creative in future.