The simple answer is because the angel of the Lord is God in the person of Jesus Christ before He incarnated.
Notice at Genesis 22:1 it says, "God tested Abraham."
At Genesis 22:9 Abraham arrived at the place where God told him to go. Vs10, "And Abraham stretched out his hand and took the knife to slay his son." Vs11, "But the angel of the Lord called to him from heaven, and said, "Abraham, Abraham!" And he said, "Here I am."
So why in the world does this angel of the Lord calls out to Abraham from heaven? (At Exodus 20:22, God speaks from heaven). In fact, God did not have any trouble speaking from heaven at Mark 1:11 in the NT. "and a voice came out of the heavens, "Thou art My beloved Son, in Thee I am well pleased."
Moving along, Vs12, "And he said, "Do not stretch out your hand against the lad, and do nothing to him; for now I know that you fear God, since you have not withheld your son, your only son, from Me." (Why does the text say Isaac was Abraham's only son when Abraham had another son?)
Skipping to vs15, "Then the angel of the Lord called to Abraham a second time from heaven. Vs16, and said, (Notice it says, "and said," not and God said.) By Myself I have sworn, declares the Lord, because you have done this thing, and have not withheld your son, your only son, Vs17, "indeed I will greatly bless you and I will multiply your seed as the stars of the heavens, and as the sand which is on the seashore; and you seed shall possess the gate of your enemies.
Vs18, And in your seed all the nations of the earth shall be blessed because YOU HAVE OBEYED MY VOICE." Now, many people bring up the proposition that the angel of the Lord is the agent speaking on behalf of God. The Jews do have the "sheluach" principle.
It is also called the Law of Agency. It deals with the status of a person (known as the agent) acting by the direction of another, (the principal). In this case the angel of the Lord is acting on behalf of God. It is also important to note that the angel of the Lord is NOT and actual angel like Michael of Gabriel.
The Hebrew word for angel is "malak." The word simply means, "messenger." At Malachi 3:1 we read, "Behold, I am going to send My "malak/angel/messenger" and he will clear the way before Me. And the Lord whom you seek, will suddenly come to His temple; and the "malak/angel/messenger" of the covenant, in whom you delight, behold, He is coming, says the Lord of hosts."
So, who cleared the way of the Lord? Please read Mark 1:1-4. It was John the Baptist who cleared the way of the Lord Jesus Christ. As a side note we know that Malachi is a prophet, well his name comes from the work "malak." The prophet Malachi is a messenger and he and John the Baptist are human beings, not angels.
So I'm going to make this bold statement! It's impossible for the angel of the Lord to be an actual angel. Secondly, it is a fact that the angel of the Lord is not only a messenger but God Himself. What's my proof? Yes, as I said the Jews have the "Law of Agency where an agent acts on behalf of a principal.
It should also be stated that the agent is limited in his duties while acting on behalf of a principal. In this case, in Genesis 22, an angel cannot swear an oath on behalf of God Himself. Since the angel of the Lord is not an actual angel, he can swear the oath because He is God.
Here's the proof from the writer of the book of Hebrews at Hebrews 6:13-16, "For when God made the promise to Abraham (referring to Genesis 22), since He could swear by no one greater, HE SWORE BY HIMSELF, vs14, saying, I will surely multiply you; vs15, And thus having patiently waited, he obtained the promise; vs16, For men swear by one greater than themselves, (in a courtroom you swear to tell the truth "So help you God), and with them an oath given as confirmation is the end of every dispute. Also, swearing an oath is a matter of one's personal conscience.
Lastly, and I almost forgot this point. It come from Genesis 22:12, where it says, "I know you fear God." God oftentimes speaks in the first person and in the third person. A good example is at Job 1:8, "And the Lord said to Satan, Have you considered My servant Job? For there is no one like him on the earth, a blameless and upright man, FEARING GOD and turning away from evil."