All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
There is no contradiction between the order to pray two units of prayer when entering the masjid and the Khateeb (the person who delivers the sermon) entering and sitting between the two sermons without praying two units of prayer, because the two units of prayer apply to the worshippers other than the Khateeb.
As for the Khateeb, he is excluded from the Tahiyyat Al-Masjid. The evidence for this is found in the actions of the Prophet who used to enter the masjid and ascend the pulpit without praying two units of prayer, as he is busy with the sermon instead of the two units of prayer.
Imam An-Nawawi said:
“It is recommended for the Khateeb to not arrive for the Friday prayer until after its time has begun, so that the first thing that he does after his arrival to the pulpit is to start delivering the sermon, because this is what is narrated from the Prophet . When the Khateeb reaches the pulpit, he ascends it and does not pray the Tahiyyat Al-Masjid, which is waived due to him engaging in the sermon, in the same manner that the pilgrim is exempted from it [Tahiyyat Al-Masjid] when he enters Al-Masjid Al-Haraam (the Sacred Mosque) because of Tawaaf (circumambulation)…”
Kashshaaf Al-Qinaa’, which is one of the books of the Hanbali School, reads, “It is a Sunnah (i.e. it is permissible) to pray the Tahiyyat Al-Masjid, two units of prayer or more, for every person who enters the masjid, whether with the intention of sitting in it or not, for the general narrations (in this regard), with the exception of the Khateeb who enters for the (Friday) sermon, as he does not pray the Tahiyyat Al-Masjid...”
Allah knows best.