Unless something has changed in the last ten years or so, they aren't told the categories beforehand. I had a friend that was on Jeopardy, and he did pretty well until the Final Jeopardy category was Ballet.
And, to answer your question, they just know a lot of stuff. Actual contestants will read almanacs and encyclopedias to prepare. Didn't you ever know any
college bowl contestants? When I watched Jeopardy regularly, I got about 75% of the questions (answers?) right. Of course, there's much less pressure at home than in front of a studio audience. I haven't watched it much in years, though. I should.