These words are innovated. There is no doubt that there is no god but Allaah and that nothing will abide forever except Allaah, but the fact that it is said in this manner as described in the question is bid’ah, because every way of drawing close to Allaah or of worshipping Allaah that was not done by the salaf (early generations of Islam) is an innovation (bid’ah). Similarly, saying “Yaa Rahmaan, yaa Rahmaan” at the time of burial is also an innovation.
The Sunnah for the one who follows a funeral procession is to ponder and think about his fate and that he is now walking behind the bier, but one day he will be the one whose bier is being followed as this bier is being followed, so he should ponder his own deeds.
At the time of burial, when the burial of the deceased was finished, the Prophet (peace and blessings of Allaah be upon him) would stand at the graveside and say: “Pray for forgiveness for your brother and ask for him to be made steadfast, for now he is being questioned.” This is what is prescribed in Islam. End quote.
Shaykh Muhammad ibn ‘Uthaymeen (may Allaah have mercy on him).