Why did Jim often stay on the raft in Huckleberry Finn?

Was it because people would catch him as a runaway slave?

Yes.