The answer to this question can be readily deduced from the context of the previous verse. So, let me quote Matt 23:8, 9
But you are not to be called ‘Rabbi,’ for you have one Teacher, and
you are all brothers. And do not call anyone on earth your father, for you have one Father, who is in heaven.
Note the highlighted sentence - "You are all brothers". This is not literally true but true spiritually. That is, this teach from Jesus is talking about spiritual relationships and NOT biological relationships.
Jesus is emphasizing that in the spiritual kingdom of God, all are equal, as "brothers". Therefore, no one is our father because God is our spiritual Father.
By contrast, the fifth commandment in Ex 20:12 is discussing the required respect to be given to elders and biological fathers - a completely different matter.
Therefore, there is no contradiction. The Pulpit commentary observes:
Verse 9. - Your father. This was the title given to eminent teachers
and founders of schools, to whom the people were taught to look up
rather than to God. It was also addressed to prophets (2 Kings 2:12; 2
Kings 6:21). In ver. 8 Christ said, "be not called;" here he uses the
active, "call not," as if he would intimate that his followers must
not give this honoured title to any doctor out of complaisance, or
flattery, or affectation. Upon the earth. In contradistinction to
heaven, where our true Father dwells. They were to follow no earthly
school. They had natural lathers and spiritual fathers, but the
authority of all comes from God; it is delegated, not essential; and
good teachers would make men look to God, and not to themselves, as
the source of power and truth. Matthew 23:9