Praise be to Allah, and peace and blessings be upon the Messenger of Allah. To proceed:
There is no contradiction between the two hadiths, because each one discusses a different aspect of faith.
The pillars of faith are the great foundations upon which belief is established. They are six, as explained by the Prophet ﷺ in the Hadith of Jibril:
These are the foundations of creed without which a person’s faith is not valid.
The branches of faith include all outward and inward words and actions that fall within the meaning of faith. Therefore, the Prophet ﷺ said:
“Faith has more than seventy branches. The highest of them is the statement: ‘There is no deity worthy of worship except Allah,’ the lowest of them is removing something harmful from the road, and modesty is a branch of faith.”
The branches of faith include:
Allah described some righteous actions as faith because they are part of faith and are not separate from it.
Allah, the Exalted, says:
“And Allah would never cause your faith to be lost.”
(Qur’an 2:143)
The scholars explained that the word “your faith” in this verse refers to the prayers that the Muslims performed facing Jerusalem before the direction of prayer was changed.
The pillars of faith are the six foundations of creed in which every Muslim must believe. The branches of faith are all the inward and outward qualities and actions of faith. They are more than seventy branches and include the actions of the heart, tongue, and limbs. Therefore, there is no contradiction between the two hadiths. Rather, each one explains a different aspect of the reality of faith.
And Allah knows best.