There are multiple types of Ethernet frames. The common ones today are Ethernet-II and 802.3 ethernet.
They both start the same but diverge when they get to the ethertype/length field. From Wikipedia "Ethernet frame"
The "Ethertype or length" field is how you tell whether it is EthernetII or 802.3. If the field is less than 1500 then it means that the frame is 802.3 and the field specifies the length.
So when you put 0x0027 in that field, you are saying that your frame is 802.3 ethernet and it's length is 39 octets. That also means you can expect a LLC header immediately after the length field.
802.3 ethernet header format from geeksforgeeks.com. The DSAP/SSAP fields specify the content for 802.3. Not the length field (which you thought was the Ethertype field).
Here's a picture of a wireshark capture of a spanning tree frame. The length field is 0x0027 (decimal 39). It's followed by the DSAP and SSAP fields of 0x42 indicating spanning tree, then a control field, before you get to the data.
The other thing to realize is that switches LISTEN to spanning tree. They process the frame. Spanning tree frames are intended for switches. So if you send a correctly formatted spanning tree frame to a switch, it will consume the frame and update the spanning tree application state on the switch accordingly (which may trigger other spanning tree BPDU's to be sent).
And if you send an incorrect spanning tree BPDU to a switch, it will drop it because it's supposed to process it, but it's wrong.