Mutect2 uses a sophisticated approach to differentiate between somatic mutations and germline mutations. It employs a Bayesian model to evaluate the likelihood of each potential variant, considering factors such as sequence context, base quality, and mapping quality. The tool also integrates various filters to eliminate false positives, ensuring high specificity and sensitivity in mutation detection.