if a transaction has 10 confirmation, does bitcoin-core check if the txid exists in the last 10 blocks? or its calculated based on transaction block number?
First of all, multiple confirmations does not mean that a transaction or its hash is included in multiple blocks. One confirmation means that a transaction was included in a block. More than one confirmation means that blocks have been mined on top of the block containing the transaction.
So what Bitcoin Core does is it records the hash and height of the block that contains the transaction, subtracts the current main chain height from the block height and then adds one. This counts the number of blocks mined after the block containing the transaction and then counts the block itself. This results in the number of confirmations the transaction has.