Where is the part where Lincoln ordered the judge arrested?
You're still confusing several key details of the case. Merrick was not arrested into the custody of the military but rather placed under house arrest. Murphy's attorney Foley is the one who was arrested into the custody of the military (i.e. a "normal" arrest rather than a house arrest).
As for the orders, there were several. Porter is the one who ordered to his men that Merrick be placed under house arrest until the duration of the Murphy case (the idea being to prevent him from returning to his courtroom to hear the case). When the other judges found out about Merrick's situation they issued a contempt of court summons against Porter.
Porter responded to the contempt order by informing the court via surrogate that Lincoln authorized him to act as he did and ordered the district attorney to prevent the ruling of contempt from being served against Porter.