Because it's a function of how the particular layer 2 switching works.
In the case of Ethernet, MAC (media access control) addresses are used for each Ethernet port. This is a physical address assigned to the Ethernet port identifying it. An analogy is a neighborhood street. Your LAN/layer 2 network is defined as Pennsylvania Ave. But how each house is identified uniquely is by the house number. The MAC address is the same as the house number in this analogy. To expand into Ethernet switching, a piece of data is packaged into what's called a frame. The frame has a section at the beginning of it called a header. In this header, contains information such as the source of the frame and destination the frame is to be sent to. The source and destination information contains MAC addresses. When the source sends data onto a layer 2 environment, it puts its own MAC address in the source field of the header and then puts the MAC address of the destination host (the intended receiver) of the data. The frame then gets sent out of the Ethernet port of the source. Because we're talking about layer 2, the source is connected to a switch. The switch has what's called a MAC address table. This MAC address table is a lookup area where the switch keeps track of what MAC address was heard on which switch port. This is the reason why switching is so much faster and efficient than using hubs that are layer 1. Because data is directly sent to a destination most of the time where as with a hub, all traffic is sent to all ports on the hub. This direction of traffic on a switch via the use of a MAC address table is what you're referring to as the "routing" of traffic.
In the case of Ethernet, MAC (media access control) addresses are used for each Ethernet port. This is a physical address assigned to the Ethernet port identifying it. An analogy is a neighborhood street. Your LAN/layer 2 network is defined as Pennsylvania Ave. But how each house is identified uniquely is by the house number. The MAC address is the same as the house number in this analogy. To expand into Ethernet switching, a piece of data is packaged into what's called a frame. The frame has a section at the beginning of it called a header. In this header, contains information such as the source of the frame and destination the frame is to be sent to. The source and destination information contains MAC addresses. When the source sends data onto a layer 2 environment, it puts its own MAC address in the source field of the header and then puts the MAC address of the destination host (the intended receiver) of the data. The frame then gets sent out of the Ethernet port of the source. Because we're talking about layer 2, the source is connected to a switch. The switch has what's called a MAC address table. This MAC address table is a lookup area where the switch keeps track of what MAC address was heard on which switch port. This is the reason why switching is so much faster and efficient than using hubs that are layer 1. Because data is directly sent to a destination most of the time where as with a hub, all traffic is sent to all ports on the hub. This direction of traffic on a switch via the use of a MAC address table is what you're referring to as the "routing" of traffic.