When a switch first is booted it starts immediately listen to all its ports and register the addresses seen (source address in the Ethernet packet) in a database with a note on of which port it was seen. This database is called the forwarding database.
When a packet arrive on any port the switch will look up in its database if the destination is present and in that case forward the packet to only this port. If the destination address is not present in the database the packet will be sent out on all its ports. This well always be the case for broadcast/multicasts packets.
Most modern switches has a functionality to "mirror" ports. All traffic from and to chosen ports will also be sent to a named port where you can connect for example a sniffer. A common method is to mirror the WAN port, going to a router or firewall to see the WAN traffic
Below follows a table with common vendor and switches that supports port mirroring.
The headlines link to the vendor and their description of port mirroring
a description.