The three-year lock-in
The reinvestment exemptions come with a condition that is easy to forget once the first sale is behind you: the new house has to be held for three years. If you transfer it within three years of buying or constructing it, the exemption you claimed is recaptured. Note that this lock-in is three years, not the twenty-four-month period that now decides long-term status generally; the reinvestment rules kept the three-year line.
So the question on selling a house you bought with exempt money is simply how long ago you bought or built it. Inside three years, the recapture rules below apply. Past three years, the exemption is safe and the new sale is taxed on its own footing. Getting the date right is the whole of it.
How Section 54 recaptures the exemption
Where you had claimed Section 54, the recapture works through the cost of the new house (Section 54). For computing the gain on this sale, the cost of the new house is reduced by the amount of the capital gain you exempted earlier. So your cost is artificially lowered, which produces a larger gain on the sale of the new house, and because you held it less than three years, that gain is short-term, taxed at your slab rate rather than the concessional long-term rate.
The effect is that the tax you saved the first time is effectively recovered through a bigger, higher-rate gain on the second sale. A practising CA computes this correctly, applying the reduced cost, so the return reflects the recapture rather than understating the gain and inviting a notice.
How Section 54F recaptures, and the TDS
Where you had claimed Section 54F, the mechanism is different and more direct (Section 54F). The gain you had exempted is deemed to be long-term capital gain of the year in which you sell the new house, and taxed as such, separately from and in addition to any gain on the new house itself. So you are taxed both on the recaptured old gain and on whatever the new house made.
Either way, as an NRI selling the new house, the buyer deducts TDS under Section 195, and a Form 13 certificate can set that to your real position. Because the recapture makes the true taxable amount larger than a simple gain on the new house, getting the computation and the certificate right matters, so the withholding and the return line up and the recaptured tax is paid correctly rather than surfacing as a demand later.