Some third-party apps or files can inject persistent malware that survives a standard factory reset. Flashing official firmware cleans the system partition completely.