Hannah did not have seven children. After Samuel, she gave birth to three more sons and two daughters, thus a total of six children (1 Samuel 2:21). The reference in this case is not to her but to the fact that the Lord gives the perfect number of children. In the Bible, the number seven is often used as a poetic idiom for perfection.1
5 Those who were full have hired themselves out for bread, but those who were hungry have ceased to hunger. The barren has borne seven, but she who has many children is forlorn.