My ghostwriting gigs came about because I already had a relationship with a publisher that put out some of my books. I’m sure landing a ghostwriting gig with just writing samples has happened for some, but it’s my understanding that the standard way to get ghostwriting gigs is: Write a book and get it published, which gets you on a publisher’s radar.
It’s much the same way you can’t just get a job as a script doctor. You have to have written a produced screenplay first.
As for doing it in tandem with a 9-5, it’s totally possible. I did it both times. But, it obviously depends on personal bandwidth.
[EDIT: I should add that a few professions lead to ghostwriting or co-writing gigs more naturally, like journalism or game writing.]