Anybody can be credited for songwriting as long as they are registered at the copyright office. Some bands credit all of the members, even if a particular member had nothing to do with it. Many Lennon/McCartney songs were written separately, but they made an agreement to credit each other. Some add family members or friends to help them out financially. In the 1970s, James Brown credited some songs to his daughters (who were under 10 at the time) to get around the tax man. Some songwriters make deals to credit someone to get their songs recorded, like Colonel Parker did with Elvis Presley. Elvis never wrote songs. There's also the case of ghostwriters who get paid a fee for each song they write, but the songs are credited to someone else, who get the royalties. Songwriters for hire also get a fee, but they are usually credited although the songs are owned by someone else like a record label. Decades ago, label heads would add their names to songs of their acts to make money, often without the knowledge of the writer. In some cases, a performer who writes might write or co-write a song with another act who are on another label. They might decline a credit to avoid label politics, like the label might refuse the other act to release it with their act. This is also why some are not credited for singing and/or playing or they use a fake name.