Me personally, I fool around with a lot of languages, and sometimes I don't quite keep every project up to date with the latest version. For work, the situation is even more challenging, because I don't have the authority to go tell teams to upgrade or not upgrade, but sometimes I need to build their projects.
None of this is really Mac specific. I used to use virtual box for this, which worked pretty well. I could set up a baseline environment and snapshot new boxes with new language revs.
Docker can kind of cover this, but I tend to over do it, breaking things out into the one you build with, and the one you run with, and it's fine, but it's a lot to keep in my head. So, I'm kinda flakey about that.
Now, I'm slowly building up some proficiency with nix. I think this is what I really want, to swap out the whole chain of system dependencies, and build docker containers or vms out of that if I need them.
Perhaps I'm a poor sysadmin. _everything_ locally installed makes things real weird after a while (years).