God's intent was for Samuel to go to Bethlehem where he'd find the new king (Saul’s replacement) and anoint him, hence the horn (1 Samuel 16:1).
We don't really know how the communication between Samuel and God happened but we do know it happened and that Samuel knew who God wanted because in 1 Samuel 16:8
Then Jesse called Abinadab, and made him pass ...
There was no anointing "in a horn" but "with" a horn of oil. That is what the word "anoint" means - to "consecrate with oil" for a special task or function. The horn was simply the container that held the sacred anointing oil.
In the case of 1 Sam 16, the prophet Samuel anointed David as future king of Israel by ...
Samuel used a flask of olive oil to anoint Saul in
1 Samuel 10:1
Then Samuel took a flask of olive oil and poured it on Saul's head and kissed him, saying, "Has not the LORD anointed you ruler over his inheritance?
God specifically told Samuel to use a horn in
1 Samuel 16:1
The LORD said to Samuel, "How long will you mourn for ...
English Standard Version
I cry out to God Most High, to God who fulfills his purpose for me.
It is important to point out that the word "purpose" is not in the original Hebrew.
New American Standard Bible
I will cry to God Most High, To God who accomplishes all things for me.
Verb - Qal - Participle - masculine ...
In the beggining of that Psalm, we can read in NASB
Prayer for Rescue from Persecutors.
For the music director; set to Al-tashheth. A Mikhtam of David, when he fled from Saul in the cave.
This was a prayer for aid. Why would David need aid? As the beginning also implies, David fled from Saul to a cave (1 Samuel 22:1-2).
Given the context, the purpose God ...