At least 31 inmates have been found dead in a prison in southern Ecuador, including 27 who had been hanged, officials say.