I know it's a dApp web3 browser, a wallet. But which ethereum client is used in the back end to interact with block chain? How the same account is able to connect with all networks (mainnet,testnet, private net)? If anyone know the working of Metamask/ the layer of Metamask ,please share it here.It will be very useful for all learners.
@AngeloBad is correct that, by default, Metamask uses Infura, but Metamask also allows you to use any RPC enabled Ethereum client as its Web3 provider.
To elaborate on the references to the fact that Metamask uses Infura (unless you explicitly specify your own RPC endpoint), this article on their blog has a couple of useful architectural diagrams that helped me wrap my head around it: https://blog.infura.io/infura-boomerang-architecture-6dc27ef56646
Just note that it's a few years old so things may have evolved a little since then, but conceptually it's still the same.