Hannah named the child Samuel because, she said, she asked for him from the Lord. The name is linked in the text to her request and God’s answer. 1 Samuel 1:20
Early the next morning Elkanah’s family worships, then travels home to Ramah. After returning, Elkanah has sexual relations with Hannah, and the story credits Yahweh with “remembering” her—meaning her long barrenness is now being addressed. In due course Hannah becomes pregnant and gives birth to a son. These verses conclude the first movement of Hannah’s crisis and petition: her childlessness, distress at Shiloh, private prayer, and Eli’s response that she should go in peace (1 Samuel 1:9–18).
These verses move from Hannah’s prayer at Shiloh to the start of its visible outcome. The family worships “before Yahweh,” returns home to Ramah, and ordinary married life resumes.
A careful answer keeps the immediate passage, the book's argument, and the whole-Bible storyline together, so the question is answered in context instead of as a detached idea.
Start with 1 Samuel 1:20, then read the surrounding section so the answer stays connected to the passage's flow.
20It happened, when the time was come about, that Hannah conceived, and bore a son; and she named him Samuel, [saying], Because I have asked him of Yahweh.