Question: "How did Abraham know that God will provide a lamb (Genesis 22:8)?"
Answer: Abraham knew that God would provide Himself with a lamb because, after years of having an immature faith, Abraham grew to fully trust that what God says He will do, He will do. In Genesis 15:6, after God had promised Abraham to give him innumerable descendants, Abraham believed in God, and it was credited to Abraham as righteousness. Initially, Abraham tried to help God keep His promise by suggesting that Eliezer be counted as his heir (Genesis 15:3) and by taking Hagar as his wife (Genesis 16). God’s plan wasn’t for either of these scenarios to provide the fulfillment of His promise. Instead, God further specified that Sarah would have a son and his name would be Isaac (Genesis 17:19). Isaac would be the covenant son through whom God would keep His promises (Genesis 17:21).
Just as God had promised, Isaac was born (Genesis 21:1–2). Some years later, God tested Abraham’s faith, telling Him to take Isaac to Mount Moriah and sacrifice him to the Lord there (Genesis 22:2). This was a horrifying and grievous request, yet Abraham started off in the morning to do exactly what God had told him to do (Genesis 22:3–6). As they were making the journey, Isaac observes that there is no lamb for the sacrifice, and he asks his father about that oddity (Genesis 22:7). Abraham responded to his son that God will provide Himself a lamb (Genesis 22:8). When they arrived at the right place, Abraham bound his son and was about to take the prescribed action and kill Isaac (Genesis 22:9–10).
The author of Hebrews tells us what Abraham was thinking—how he could be willing to kill his son, and how he could know that God will provide Himself a lamb. When God told Abraham to sacrifice his son Isaac, Abraham considered that God was able to raise people from the dead (Hebrews 11:19). God had promised Abraham that Isaac would be the covenant son, and that from Isaac God would raise up a mighty nation in fulfillment of the promises God had made to Abraham. God had already miraculously kept His promises—that Isaac was even born was a miracle in itself. Abraham had learned that God is faithful. At first, Abraham simply exercised faith (Genesis 15:6), and God counted that to Abraham as righteousness (as He does with us when we believe in Him). But part of growing in our relationship with God is increasing in confidence that He is able and willing to accomplish what He has said. Because Abraham had seen God’s faithfulness, when this uncharacteristic request of human sacrifice was made, Abraham trusted God that He knew what He was doing. Abraham knew that, even despite this strange and awful request, God would provide and God would keep His word.
Before Abraham could bring the knife down to strike his son, the angel or messenger of the Lord called out to Him from heaven acknowledging that Abraham had passed the test and should not kill Isaac (Genesis 22:11–12). Of course, God never intended that Abraham would actually kill Isaac. He simply wanted to show Abraham that, no matter how impossible the circumstances, Abraham could trust God. As Abraham looked up, he saw a ram caught in a thicket nearby and offered the ram as a sacrifice instead of Isaac (Genesis 22:13). Abraham then acknowledged that God had provided for His word to be kept, and he named the place "Jehovah-Jireh," which means "The Lord Will Provide" (Genesis 22:14).
While Abraham’s weakness of faith is chronicled in Genesis 18—21, God did not reject him or punish him for that immaturity. God did, however, provide him opportunities to grow and then puts him to the test so he can demonstrate that growth. Abraham learned that God is faithful, and even when we are unsure of how God is going to keep His word, we can be certain that He is faithful and that He will keep His word.