A switch is the major network device enabling communication on the data link layer (L2) in the OSI networking model. Usually, "switch" refers to an Ethernet switch.
Basically, nodes in the connected network can send network packets (frames in correct jargon) to each other that are addressed to their hardware addresses. Each frame carries a marker (EtherType) indicating for which "upper-layer" protocol it transports data.
Commonly, that upper-layer protocol may be an IP protocol (in OSI's network layer L3) that enables communication between nodes in different L2 networks using routers as gateways.
On top of IP sits a transport-layer protocol (L4) that enables communication between applications - e.g. a web browser and a web server.
These then speak a common application-layer protocol (L7) - SMB, FTP, HTTP, .... - that allows them to actually exchange data.
From the architecture POV, a switch is multi-port bridge, just like a wireless access point that interconnects a wireless LAN. These work somewhat differently than a switch, but their general purpose is the same.