You cannot undo a confirmed transaction trivially. That is one of the key benefits of a network like Bitcoin.
If your tx has only 1 confirmation, you might yet be able to drop it by mining two blocks on the parent of the block that contains tx_1. However, this requires you to have enough hashpower to be able to do so before someone extends the chain building on the block containing tx_1, which is non-trivial. Additionally, even if you succeed in this, there is still a chance that someone might mine on the block you dropped and turn that into the longer chain again.
Usually, blocks which have been confirmed 6 times are considered irreversible. Practically, unless you have access to a large amount of hashpower, even 1 confirmation is effectively irreversible on the bitcoin chain (although orphan blocks do occasionally happen)
Say I am tracking a specific bitcoin transaction 'TX_1'. A confirmed block had the transaction information after I decoded the block, and I updated my database as : {transaction: 'TX_1', 'confirmation': 1} now how do I increment the number of confirmation, assuming I am still listening to the network through ZMQ. Should I expect the same transaction 'TX_1' to be present in upcoming blocks? – merklexy – 2018-05-17T14:46:14.390
When you receive the next block, check the prevblock hash. If it matches the block with your tx, increment by one. For the n+2 block, check the prevblock hash against the n+1 block, and increment by 1. So on and so forth. As long as new blocks keep building upon a chain including the block with your tx, it keeps adding confirmations – Raghav Sood – 2018-05-17T15:00:59.260