Although people want to make this a church/state thing it isn't, it actually makes a lot of sense to me. There's two real motives behind community service sentences. These first it the one most people think of: you have a debt to society, you are repaying it by working for society. The other is that, by performing community service, the individual becomes a part of the community. Those who are a part of the community are less likely to commit crimes in said community. Also, the community can provide a support network for the individual. Clearly not all community service fulfills that second goal, and clearly it doesn't work out that way for everyone.
However, another great way to be a part of a community, even if you aren't religious, is to be a part of a church. The judge didn't say "attend services as United Methodist of 3rd street." The judge may just be trying to push that second goal, helping those sentenced find a community and support network.
Or the judge may be a bible-thumping type who thinks criminals need to "find Jesus"
But I like to hope for the former