What it does
Reloading a shotgun is one of the longest commitments in the game and it happens at the worst possible moment. Switching away and back cuts the animation short while keeping the shells you have already loaded, so you come back out shooting instead of standing there.
Why it exists in the code
The reload is an animation with state attached, and the weapon switch overrides that state rather than waiting for it. What was loaded stays loaded. This is the clearest example of a legacy behaviour that reads like a bug from the outside and is load-bearing from the inside.
This behaviour is preserved deliberately. It is not on a list of things to fix.
The mistake everyone makes first
Switching before any shells are in. You cancel the reload and get nothing for it, which leaves you holding an empty gun in the middle of a fight — the exact situation the technique exists to avoid.