There is already a good almost complete answer here (but missing the cryptography explanation):
How is a wallet’s balance computed?
Is a bitcoin wallets balance calculated on the client computer app? eg. Leger Live
How is bitcoin wallet balance calculated cryptographically?
Does Ledger Live app check/compare each transaction+hash & transaction+signature hash like mempool nodes do?
Or does it only look at the unspent output addresses and check if they are children of wallet public key? If so how does it do this in cryptography terms?