I started reading about how bitcoin transactions are processed and I came across the Merkle Tree. I learned that one of its purposes is to prevent nodes from storing the entire bitcoin transaction history. The bitcoin paper also mentions that after a block is buried under enough blocks, the whole merkle tree can be deleted and the merkle root can be kept in that block. However, none of this whole process mentions nodes keeping track of transactions. So how would a node be able to access previous transactions like the initial bitcoin transaction?
1 Answer
The Merkle tree construction's purpose is enabling cheap proving of the existence of transactions. If some node which doesn't have a transaction, but it has the Merkle root, it can be told by another node which does have the transaction about it, together with a path connecting it to the root, and the receiving node can be sure that that transaction was indeed included in the block whose Merkle root it has.
As for how nodes store transactions which they do want... that is unrelated, and very dependent on the kind of software you're talking about.
Bitcoin full nodes, for the purpose of validation blocks and future transactions don't actually need to keep transactions at all, and for example Bitcoin Core can run in "pruning" mode where this is done. Instead, just a database of all unspent transaction outputs are kept, indexed by the txids of the transactions they were created by. This is sufficient for validation, and much faster than constantly looking up transactions in all history. There exists node software that works differently.
Wallets will generally only keep transactions that are relevant to the user's balance.
Indexing software, such as that powering blockchain explorer websites, or server software queried by lightweight clients, will generally keep all transactions ever, plus a ton of indexes to quickly find any of them.