These are just backdoors as a vulnerability class. It
does happen occasionally even in high quality widely used libraries, but it's very rare and usually quite sophisticated (e.g.
https://en.wikipedia.org/wiki/XZ_Utils_backdoor in 2024). A lot of these attacks, even when highly sophisticated, only really work when the attack payload can be hidden in a binary--it's very very hard to insert a useful backdoor into the source code of an actively maintained project that receives regular code reviews without anyone noticing (which is not to say it's impossible).