It only sends a message to a device if it requests the message. It does not broadcast the message out of each of the ports.
Switches can be multi layered as well. This means some have additional features which can include the ability to route packets. They are widely known as a layer-3 or multilayer switches.
These switches can also be used as an extra form of security. A switch will only send out a message to a computer behind the network. If the message coming from outside the network does not have a proper package IP address that is on the system the message will be discarded.
One downside to having a layer-3 switch is the time it takes to find the MAC address in the packet and decide where to send the information. This latency can sometimes be a small problem.