J.I. Packer accurately captures how union with Christ is the mechanism of imputation:
“[God] reckons righteousness to them, not because he accounts them to have kept his law personally (which would be a false judgment), but because he accounts them to be united to one who kept it representatively (and that is a true judgment)”
—J. I. Packer, “Justification,” in Evangelical Dictionary of Theology, ed. Walter A. Elwell [Grand Rapids, MI: Baker, 1984], p. 596.