After Imam Sajjad (AS), the rest of the Shiite Imams were both the son of Imam Hussein (AS) and the son of Imam Hassan (AS); Because the mother of Imam Baqir (AS) was the daughter of Imam Hassan (AS) and his father was the son of Imam Hussein (AS).
The fact that the Imamate has continued from the generation of Imam Hussein (pbuh) and after each Imam his son reached the Imamate does not mean that the other children of the Ahl al-Bayt (pbuh) did not have any position with God or that they were sinners. , But also many children of the Imams (PBUH) have been pure, knowledgeable and brave people and have rendered very valuable services to Islam. Among these people is Hazrat Abdul Azim Hassani (buried in the city of Ray in Iran), one of the prominent students of Imam Hadi (as) and a descendant of Imam Hassan (as), who has valuable scientific and jurisprudential works.
In any case, and as the Shiite beliefs are based on it, "Imamate" is in fact a divine thing that is determined by God, and the one who has the highest position in terms of science and morality, etc. God is chosen as the Imam. Jacob also had 12 children, and the line of prophecy continued in the generation of one of them [and the next prophets were not chosen from the generation of Joseph himself]. Even "Benjamin", who was the body brother of Prophet Yusuf, was deprived of this position. The answer to these has been stated by God in one word in verse 124 of Surah An'am:
اللَّهُ أَعْلَمُ حَيْثُ يَجْعَلُ رِسالَتَه
God knows best where to place His mission
https://makarem.ir/main.aspx?typeinfo=44&lid=0&mid=406309&catid=