Switches are meant to provide a connection/connecting multiple devices.
Switches can operate at either layer 2 (data-link) or layer 3 (network). The caveat being that layer 2 switches can only operate at layer 2 making it exclusive to that layer while layer 3 switches can be used for either layer 3 or layer 2.