Each bitcoin node keeps an index of 'unspent transaction outputs' (the "UTXO set"), which is updated with each new block received. At the genesis of the network, the UTXO set was empty. With each block after the genesis block, the UTXO set was slowly populated, as each new block would contain some number of transactions (that create/destroy UTXOs).
Each bitcoin transaction specifies some number of inputs (other than the coinbase transaction in each block, which is a special transaction that has no inputs), and these inputs must be valid, existing UTXOs in the UTXO set. These UTXOs are 'consumed' entirely as inputs, and thus deleted from the UTXO set that the node keeps track of.
Each bitcoin transaction also specifies some number of newly created outputs, which are added to the UTXO set.
So when checking to see if a transaction is valid, the node will check to ensure that all inputs to the transaction are valid, currently existing UTXOs. Under the hood, each input is specified by the transaction ID, and the outputs index, and it is this data that the node uses to lookup the UTXO, as one step towards determining the validity of said transaction.