Finding a transaction in the blockchain
After searching about this, i found out that each full node maintains a database with the set of unspent transaction outputs (UTXOs) in the memory. So When a new transaction is added, its UTXOs get updated accordingly (source). Also, a full node keeps track of all transactions that ever happened (source) and offer this:

Filtering transactions and blocks on behalf of lightweight nodes so that lightweight nodes do not need to download every transaction ever made on the network in order to find their own transactions.
Serving historical full blocks to nodes that have been offline for a while.
Transmitting new transactions from users to miners.
Broadcasting new blocks from miners to other nodes.

The RPC used for this call getrawtransaction that takes as an argument a TxID which is hashing twice the transaction data and gives you back the transaction you are searching for.