According to Paragraph 156 of Queens Regulations for the Army 1881 there were two principal reasons why a man might be removed from civil prison before completion of his sentence. The first is that his Regiment was proceeding overseas and he was required to join them, and secondly, that he was required to face a further court martial. However neither of these situations arose in James Coleman's case which leads to two other possibilities.
The first is that he has released early under instructions of the Home Office. While he was in a civil prison he was entirely subject to Home Office rules and procedures. However given that he had only served around 6 months of his 2 year sentence this seems unlikely.
The fourth possibility is that he was granted clemency by the Army. This is covered in paragraph 166 of QRs, and in my view I think this is the most likely explanation. In other words his original sentence was judged to have been too harsh, or that further information became available about the circumstances of his capture which pointed towards his innocence.
On a separate note, are you aware that he joined the Militia on 16 May 1896 before transferring to the Regular Army exactly one month later? Both sets of paperwork were completed by the same Recruiting Sergeant Charles Fletcher. This may have been some sort of ruse by which he received two bounties, and for which Sgt Fletcher would also have been paid extra. You will find the service record on FindMyPast using his militia number 4598.