I think Matthew was speaking about periods of time not just speaking about how many kings.
First of all, The word Generation can also mean an age (i.e. the time ordinarily occupied be each successive generation), a space of 30 - 33 years https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?Strongs=G1074&t=KJV
Kings names were being used to represent some generations or some periods of time; names have not to be counted. (Count the periods of time themselves Matthew mentions.)
To understand Matthew is to begin with reading his words to know what he was thinking in generations and how and when it begins and ends.
So all the generations from Abraham to David are fourteen generations;
and from David until the carrying away into Babylon are fourteen
generations; and from the carrying away into Babylon unto Christ are
fourteen generations... (Matthew 1:17 KJV).
So if we look closely to the first period Matthew speaks of to know its beginning and end, we will see Matthew says it begins with David and ends with a period of time, a moment, an event (did not end with another king's name) and Matthew mentions the event and it is the Babylon Captivity or as the KJP puts it the carrying away into Babylon.
So the generation here is from David to carrying away into Babylon.
In this period Jechonias and his brothers were born. (Matthew 1:11 KJV)
Another period or generation Matthew speaks about also begins not with a king but with another period of time. Matthew describe this period as "from the carrying away into Babylon ".
From carrying away into Babylon unto Christ was another period
that caused another dramatic and different experience to the people.
In this period Jechonias and his brothers were brought to Babylon. (Matthew 1:12 KJV)
If we want to count kings (as represent generations) like many do, we have to count Jechonias two times as he represented two different periods and generations. This might also was in Matthew mind; but basically as we see Matthew used GENERATIONS as PERIODS OF TIME in his mind when he was meditating in Jesus' time of birth and relating that to Israel history as it is so clear in (Matthew 1:17 KJV) and less clear when he mentioned the Babylon Captivity when he mentioned Jechonias.