Having dabbled in some of this for a hobby project (not a window manager, but adjacent), it’s because the official APIs to do these things with are limited. You end up relying a lot on undocumented private APIs and hacks, which are flaky both due to their undocumented internal-use nature and because the OS isn’t designed to play nice with significant meddling with window/process management, which results in the OS and third party app frequently stepping on each others’ toes.
In fairness, I’ve encountered similar flakiness when using third party window/desktop manager utilities on Windows. Commercial OSes in general just aren’t designed with that kind of flexibility in mind.