STP how a switch identifies a BPDU
When deploying Spanning Tree Protocol (STP) of any type, switches will exchange Bridge Protocol Data Units (BPDUs) of various types to allow STP to function correctly. Beyond simply reading the contents of a BPDU, a switch will recognize that a particular is a BPDU by the information found within the Ethernet header.
Take a look at this Wireshark capture of a BPDU frame.
Note that this BPDU is encapsulated within a Logical Link Control (LLC) layer PDU, which contains the information in the Destination Service Access Point (DSAP) field as a Spanning Tree BPDU, with a code of 0x42. This tells the switch that the encapsulated information is an STP BPDU.
But even that LLC layer is encapsulated within an IEEE 802.3 Ethernet frame, which in turn uses a destination MAC address of 01:80:c2:00:00:00. This is a well-known destination MAC address defined by IEEE 802.3D as the Spanning Tree for Bridges destination address.
All of the above information tells the switch that this is a BPDU, and it is interpreted as such.