That’s because the Switch’s USB port isn’t actually a USB-C. Their port falls outside of the standard size/dimension specs, because they wanted the Switch to slide smoothly into the dock instead of having a positive click like a standard USB-C should.
This is why using a standard USB-C on your Switch can actually brick the device. Since the port is non-standard, the pins are much easier to accidentally short when plugging a standard USB-C into it. There was a big string of people complaining about bricked devices shortly after the Switch launched, and eventually players just learned to only use the official Switch chargers. But that’s only necessary because Nintendo told the USB-C standard to go fuck itself, and made a port that is almost the same (and will technically accept a standard USB-C port) but does everything slightly differently.
The Switch charger also has a power switching option, since the Switch draws more power when it’s docked than when you plug it in directly. So the power supply is set up to detect whether or not the dock is connected, so it can supply more power.