Praise be to Allah.
People offer supplications such as this in two scenarios:
The first scenario:
It may be said by way of showing kindness to a friend, and is not meant literally; it does not mean that the speaker is praying against himself. What appears to be the case is that this comes under the heading of idle talk, that is not really meant.
Allah, may He be exalted, says (interpretation of the meaning):
“Allah does not impose blame upon you for what is unintentional in your oaths, but He imposes blame upon you for what your hearts have earned. And Allah is Forgiving and Forbearing”
Shaykh ‘Abd ar-Rahmaan as-Sa‘di (may Allah have mercy on him) said:
That is, He will not hold you to account for what you utter of idle oaths, that a person may say without meaning it and without having any intention in the heart to that effect; rather he has the habit of saying such things, such as when a man says, “No, by Allah” and “Yes, by Allah”, or when he swears an oath with regard to something in the past, thinking that he is telling the truth. Rather a person will be held to account for what he intended in his heart.
This indicates that what matters with regard to the words that a person says is the intended meaning, just as the intendion is what matters with regard to the actions that he does.
End quote from Tafseer as-Sa‘di (p. 101).
Ibn al-Qayyim (may Allah have mercy on him) said:
What matters with regard to the words one utters is the intention (niyyah) and intended meaning. The ruling concerning the implication of what a person says does not become binding unless the one who said it actually meant it and was seeking the consequences of what he said. Moreover, the speaker must have wanted to utter the words he said and meant them. So there must be two intentions:
The intention to say those words, by choice;
and the intention to seek the results and consequences of what he said. In fact, intending the meaning is more important than intending to say the words, because the meaning is what one intends and the words and phrases are merely a means of expressing that. This is the view of the leading muftis among the scholars of Islam…
End quote from I‘laam al-Muwaqqi‘een (4/447).
The second scenario:
The person offers this supplication with deliberate intention, and sincerely meant it.
The gates of supplication (du‘aa’) – praise be to Allah – are open. Allah (may He be exalted) says:
“And your Lord says, "Call upon Me; I will respond to you”
“And ask Allah of his bounty. Indeed Allah is ever, of all things, Knowing”
You can balance your previous supplication and make up for it by praying that Allah grant you a long life of obedience to Him, and that He preserve your good health and good looks, and that He bless your friend with something similar to that with which He has blessed you.
The grace and bounty of Allah is immense, and the stores of Allah are full and are not decreased by spending. So there is no need to take from your good health to give it to your friend.
You also have to repent from praying against yourself, for the Prophet (blessings and peace of Allah be upon him) forbade that and said: “Do not pray against yourselves, except for good.” Narrated by Muslim (920).
And Allah knows best.