The “prevent” option would be to implement 802.1X in single host mode. It would not act on an unmanaged switch alone, but on the second device on it.
Another and more easy step would be to enable BPDU guard on all user facing ports. Again, not for the cheap unmanaged switches.
A “detection” method would be to look for ports with more than one MAC address. I didn’t look but would assume that this should also be possible with the API.
If you found this post helpful, please give it Kudos. If my answer solves your problem, please click Accept as Solution so others can benefit from it.