Switches forward frames by MAC address
A switch connects many devices on one LAN. It learns which MAC address lives on which port and forwards frames only where they need to go. If it doesn't know the destination yet, it floods the frame to every port in the same VLAN.
ARP maps IP to MAC
To deliver locally, a device needs the destination's MAC. It broadcasts 'who has 192.168.1.50?' (ARP); the owner replies with its MAC, and the switch learns the path. This is why local delivery is a two-step: resolve the MAC, then forward the frame.
VLANs split one switch into many
A VLAN puts each access port into a virtual network. Ports in different VLANs can't talk through the switch - instant segmentation with no new cabling. A trunk carries multiple VLANs between switches; a VLAN left off the trunk simply can't cross it.