Nigeria's army said it had rescued 31 civilians who were taken hostage during an attack on a church in northwest Kaduna state, while five people were found dead at the scene.