It happens from time to time that you’re asked to ghost write for someone else, which means that you transfer your authorship to someone else and will not be credited for your work. While this practice officially is illegal in most European countries (where it is legally not possible to transfer authorship) it happens more commonly in the US. But also in Europe you often see this practice happening.
Being asked to ghost write for someone is a tricky situation. Of course you might get decent money for it working on a big project but that’s about what you get from such projects. You won’t be able to use it as a reference, therefore nobody will ever know you did this job and unless your client wants to hire you for another (probably ghost) writing, you will not gain any benefit for your future out of it. Among many composers there is an understanding to properly credit any additional writers on a job but still ghostwriting happens even at the top of the game.
When being asked to ghost write, you should know that it will do nothing for your career except getting you more ghost writing jobs. So only when you really need the money, you should consider working on such a job. In most cases the cons outweigh the pros by far.