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.
Nawaafil Prayers (optional and supererogatory prayers) are of two kinds:
1) Restricted Nawaafil Prayers such as the Rawaatib Sunnah prayers that are performed before or after the obligatory prayers. This kind includes the two Rak'ahs before the Fajr obligatory prayer, the four Rak'ahs before the Thuhr prayer and the two Rak'ahs after it, the two Rak'ahs after the Maghrib prayer, the two Rak'ahs after the 'Ishaa’ prayer, the two Rak'ahs of ad-Thuha (forenoon), and the Witr prayers and so on.
2) Unrestricted Nawaafil Prayers: This kind includes all optional prayers that have no specific reason nor related to any other prayer.
As for Tahiyatul-Masjid (the prayer of greeting the Mosque), it is not among the Nawaafil Prayers that is meant in itself, but the Prophet disliked for one who enters a Mosque to sit before performing two Rak'ahs. The Prophet also ordered everyone who enters the Mosque to perform two Rak'ahs before sitting. So, whoever enters the Mosque at the time of some prayer and performs any of the supererogatory prayers that are related to any obligatory prayer, or performs some obligatory prayer, this will be sufficient for him concerning Tahiyatul-Masjid.
For more benefit on supererogatory [Sunnah or Rawaatib] prayers, please refer to Fataawa 20804, 233800, 102385, and 88390.
Allah knows best.