Yes, if Dr. X presents Dr. Y’s or Grad Student Z’s thoughts, ideas, and research as his own, then it’s definitely a no-no.
But there’s other kinds of writing in the world.
So, for example, I just got finished reading “KIng Peggy”. It’s about a secretary who worked at the Ghanian Embassy and was notified that her village had declared her King upon the death of her uncle. The book covers the first two years of her rule, while she deals with internal corruption and theft from people she ought to be able to trust, bringing running water and higher education to her fishing village, and trying to rule from 5,000 miles away, because she works in DC for most of the year (to keep her salary, which she uses for the benefit of her people) and comes into Ghana on her vacations.
The ghostwriter, Eleanor Herman, was actually with her for many of these ceremonies during the first year. Herman had been attending a function at the Ghanian Embassy, and her habit was to talk to the most interesting-looking person in the room. She sees a woman who’s standing alone, not eating or drinking, and so she goes over to talk to her. The woman explains that she is a King, and is not allowed to be seen eating or drinking in public. Herman found that fascinating— and the two collaborated to put out a book about Peggielene Bartel’s interesting path.
King Peggy was a secretary. She probably could have written her own book. But Herman was an author, who had connections in the publishing industry, and what’s more, she had the time to sit down and organize thoughts and put them together into a cohesive narrative. This is an example of a credited ghostwriter-- Bartels doesn’t pretend that she put the book together without Herman. And although Herman was present for many of the events, she does not intrude herself upon the narrative.