Hosts send frames out interfaces that are connected to switches. The packets are the payload of the frames. The frames have the MAC addresses of both the source and destination hosts in the frame header, and the switch will switch the frames based on the destination header. The switch learns where hosts are connected to it by looking at the source addresses on the frames and building a MAC address table.
A host will use ARP for IPv4 or NDP for IPv6 to determine the MAC address related to the IP address, and it uses that to address the frames its sends. The switch looks at everyu frame that enters the switch to build its MAC address table.
The default gateway is just another host connected to the switch. The source host will look at the destination IP address to see if it is on the same network. If it is, it will address the frame with the destination host MAC address. If the IP destination is on a different network, the host will address the frame with the gateway MAC address.
The switch is a transparent device, and it does not need a MAC or IP address. Managed switches have MAC and IP addresses in order to connect to the management interface, but that has nothing to do with the switching of frames.