The technical word here is, "imputation". The sins of the elect were imputed to Christ. My sins became His, as if He actually committed them. He knew no sin. He was, and alway will be, sinless. Of course, but, while He did not commit sin, my sin is now His sin. It was imputed to Him. If it had not been, I would be in big trouble.
So, when He died, He died as a sinner. An innocent sinner. A sinless sinner. If that doesn't hurt the brain too much, but He literally died as a sinner. He had to have or else it would be you and me on that tree. He had to be a crucified as a guilty man in order to free guilty men, like me.
Again, Jesus never broke a single law of God. I however, have.