How BitcoinJS sync bitcoin blockchain/transaction data?
BitcoinJS does not link directly to the bitcoin network, it is simply a collection of bitcoin-related functions. 

Taking your example above, if we wanted to create a transaction with BitcoinJS' transaction builder function, we would have to find the inputs ourselves via API's (or asking your own full node if you have one) and add then it with tx.addInput(txId, 0).