It is common that switches (and other equipment such as routers, bridges, access points) run link-layer protocols to advertise themselves. It's not universal that switches have the capability (normally it's only the more managable models) and certainly it's not universal that it's enabled. It's rare for it to be enabled across links to other organisations.
- LLDP (Link Layer Discovery Protocol) is the multi-vendor one, defined by IEEE as 802.1AB
- CDP (Cisco Discovery Protocol) is a very common proprietary one
In the simplest description, they send frames to special MAC addresses indicating their presence and details, but never forward those frames.
A Cisco router might show:
R1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,
D - Remote, C - CVTA, M - Two-port Mac Relay
Device ID Local Intrfce Holdtme Capability Platform Port ID
c8f9f9123456 Fas 3 131 S I SG 300-28 gi12
ap2.example.com Fas 1 140 T AIR-AP123 Fas 0
It's also possible to query the neighbour list by SNMP.