NBitCoin Analyzing Blockchain
You aren't doing anything wrong. You just need to be able to handle those duplicate transaction ids. It actually happens a few times before BIP 30 went into effect making such duplicate txids invalid.

These duplicates happen because the coinbase transaction in two different blocks can be exactly the same, so they have exactly the same txid. This is because prior to BIP 34, there was not anything that makes each coinbase transaction unique; you could have a transaction which pays out to exactly the same address with exactly the same amount (the block subsidy) and if you don't set a coinbase string or use an extranonce in the coinbase, you will have two identical coinbase transactions.

To handle the two cases where transaction duplication happens, you should allow an exception to the BIP 30 rule for those blocks. The transaction that those duplicate txids reference when being spent can only be the most recent duplicate transaction. Any prior ones are completely unspendable.