If you were aware of the Passion narrative in the Gospel of John, you would know that Jesus was well aware of his impending betrayal and death, had the opportunity to flee Jerusalem, but, having divine understanding of the economy of salvation, chose to remain in the Garden of Gethsamene, where He was arrested, having been betrayed by Judas Iscariot. It was Christ's obedience unto death to the will of the Father, in contrast to the disobedience of Adam, that provided the atonement for the sin of Adam. While His obedience to the point of death (not His death itself)--and an excruciating death at that--that provided the Atonement, those who brought about the death of an innocent person still sinned. Christ's sacrifice was His obedience that led to his death, not the death itself. Those who see the doctrine of penal substitution as some kind of blood sacrifice placating an angry god, similar to the human sacrifices of the Aztec, misunderstand the hermeneutic of narrative closure that Christ's obedience brings to the onset of sin resulting from Adam's disobedience.
Grace be unto you and peace.