The building wiring is sized by the OCPD.
Switches, receptacles and wiring internal to a load are sized by the load they will carry.
That's why the wire you're connecting when installing a ceiling fan is so small even when on a 15A or 20A circuit.
Think of a table lamp. That may be on a 20A circuit but the cord only needs to carry the load of the lamp. The cord cap only needs to carry that same load. Same with the receptacle.
But with building wiring that has lots of loads connected in parallel, it needs to be sized for the OCPD.