So how does ghostwriting work then? Lots of books have unaccredited ghostwriters.
https://en.wikipedia.org/wiki/Work_for_hire
I assume Germany has something like this (possibly a EU requirement). It would cover more than just ghostwritten books.
Most software is written in a similar manner. Microsoft didn't write windows, lots of ghostwriting programmers did.
But we also the right to be named as author is not a requirement to be named as author.