All perfect praise be to Allah The Lord of The Worlds, and may his peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
Performing two Raka's (Two units of Islamic prayer) before sunset prayer is a Sunnah which the Prophet (PBUH) has encouraged offering. Moreover, the righteous companions, their followers and the jurists have also practiced this Sunnah.
Ibn Hajar Al-Haythami (May Allah have mercy on his soul) stated:" Performing two Raka's before sunset prayer is a non-stressed Sunnah. It was related in Sahih Al-Bukhari that the Prophet (PBUH) said, "Perform (an optional) prayer before Maghrib prayer." (He repeated it thrice) and the third time he said, "Whoever wants to offer it can do so," in addition, many eminent companions used to come hasty near the Mosque's pillars to perform them immediately after the sunset call of prayer and even a regular man used to enter the Mosque while the sunset call of prayer is already delivered, and imagined that the sunset obligatory prayer has been performed due to performing the two voluntary Raka's by most of the people in the Mosque before the obligatory prayer." [Tohfat Al-Mohtaj V.2/P.223]. And Allah knows best.