To add to this, famous actors are media consumers themselves. They may choose to go on a show because they’re fans of the show and/or the cameo sounds like a fun time. Futurama cameos are particularly fascinating, because they allow actors to play themselves in a very surreal context, and if celebrities have a friend who tells them that the behind-the-scenes atmosphere is a lot of fun, that can be enough.
Just as an example, if you’re not aware, Danny DeVito produced, directed, and starred in Matilda pretty much because he wanted to adapt a book his daughters liked.