[God] said, Take now your son, your only son, Isaac, whom you love, and go to the region of Moriah and offer him there as a burnt offering upon one of the mountains I will tell you (Genesis 22:2)
After God allowed Abraham and Sarah to give birth to Isaac, through whom He had promised to keep his covenant of blessing them with children as the sands of the sea, God in turn requires Abraham to slay the very son through whom the covenant was to be fulfilled.
It was the test of a lifetime. But Abraham passed the test.
In his heart, Abraham slew his son. He did not love his son, or place trust in his son and what he represented, more than he loved God and trusted in his faithfulness. Abraham's hope in becoming the father of many nations was in God alone, not in his physical son.
So Abraham carried his son up to Mount Moriah, built the altar, tied up his son, lay him on the altar and took the knife to slay him, as God had instructed. The decision was made and the action accomplished first in Abraham's heart. Isaac was already dead in his heart before he took up the knife to slay him.
Because Abraham bound his son, and actually took the knife to slay him, God saw Abraham's heart. He knew his motives - that his heart was pure towards him. So God also considered Isaac dead. He knew that Isaac had already been presented to him as a sacrifice in Abraham's heart. Abraham had fully obeyed God although his son still lived.
Remember: actions, good or bad, are accomplished in the heart before they are manifested in the physical.