Is there a way to optimize the process of uninstalling and installing SSMS?
All of the relatively recent versions of SSMS install side-by-side with each other, so I wouldn't bother removing them honestly. They'll upgrade the current version if it is on the same major release.
The newer versions are being released faster and sometimes can be a bit buggy, so having an older version to fall back on can also be helpful if you encounter a bug.
As far as making it faster, you could try using a package manager like winget (in preview, but by Microsoft) or chocolatey or any other generic automation software (Ansible, etc.)
There is also the command line option of SSMS itself, as Kin mentioned. And I will also echo the warning to not be doing this regularly (or at all) on the actual SQL Server machine.