The prison chaplain surprises K. in the cathedral when he was originally expecting to meet an Italian client. And the prison chaplain's presence may have surprised you, too, even though at this late stage in the novel you should be expecting surprises.
For one thing, the prison chaplain's presence confirms K.'s paranoid feeling that the court is everywhere, watching his every move. (Guess it's not paranoia if everyone's really out to get you...) For another, the setting is quite shocking when you think of it. A cathedral, or any religious space, is a place that we think of as a kind of sanctuary devoted to reflections on higher things – morality, spirituality, and mortality, to name a few. The prison chaplain's presence shows that no space, no matter how sacred or hallowed, is exempt from the court's influence.
The prison chaplain himself is a bundle of contradictions. While at first berating K. from on high, in his perch in a side altar, the prison chaplain seems pretty chummy when he steps down from the altar. No wonder K. is so confused when, at the end of the chaplain's parable, the chaplain refuses to counsel him directly about his case. The chaplain seems more interested in all the different interpretations generated by the parable than he is about K.'s specific case. Like the parable he tells, the chaplain embodies the contradiction of the Law. The chaplain seems to have a special interest in K., just as the Law seeks out each and every individual. But like the Law, the chaplain is ultimately indifferent to individual concerns.