For those curious, this is called Focus and is pretty highly configurable after a little learning curve. You can use automations to switch modes by calendar, date/time, GPS location, connected Wi-Fi network, etc. No programming required. Programmable via Shortcuts, too!
https://support.apple.com/guide/iphone/set-up-a-focus-iphd62...
Ever since focuses got introduced, I really soured on the idea of a physical mute/ring switch.
Having my phone ring at home and vibrate when away is the most obvious use case for this feature, and yet it can't be implemented because you can't toggle a physical switch in hardware.
I know the latest generation iPhones don't have those, and I think that's the right decision, but it's still disappointing for older-gen users.