I can see you google it, found this link:
https://ninja-build.org/manual.html#_depfile and then got as far as reading the first sentence:
> gcc (and other compilers like clang) support emitting dependency information in the syntax of a Makefile.
But didn't quite make it to the second paragraph:
> (Ninja only supports the limited subset of the Makefile syntax emitted by compilers.)
Obviously Ninja can't parse and execute full Makefile syntax because then it would just be Make. But the actual information in depfiles doesn't require the full Makefile syntax; only a subset of it. And compilers output that subset, so Ninja can read it.
The issue is it's a de facto subset - a "depfile syntax" that exists by convention but the GNU authors have broken this format. As I said, unless there's a good reason to break it, that's just shitty behaviour.