How can we reconcile between the hadith in which the prophet said, "No one of you should say, 'O Allaah, forgive me if You wish, O Allaah, have mercy on me if You wish;' he should be firm in his asking, for Allaah cannot be compelled." Narrated by Al-Bukhaari, 6339, and Muslim, 2679. And there is the supplication for the Sick person narrated in Sahih Al Bukhari in which the Prophet said, "La ba’sa, tuhoor in shaa Allaah." (No worries, it is a purification, Allaah willing.)
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, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
The two ahaadeeth in reference are authentic, as the dear questioner pointed out, and there is no contradiction that causes a need to reconcile between them. The first hadeeth urges the Muslim to be persistent in supplication and to aspire to the acceptance of his supplication. It also forbids making the acceptance of supplication contingent upon the will of Allah (by adding the phrase 'in shaa Allah,' meaning 'If Allah wills'), because it is phrased as a request, such as by saying, "O Allah, forgive me and have mercy on me..." The supplication phrased as a request is the one that should not include 'if Allah wills'. This is made clear in the last part of the hadeeth, "he should be firm in his asking." Another version of the hadeeth reads, "He should have great aspiration (to the acceptance of his supplication)."
As for the second hadeeth, the phrase 'if Allah wills' is used as a good omen and a blessing by mentioning Allah and to comfort the sick person. Although its meaning implies that it is a supplication, it is actually phrased as a statement and not a request (unlike the first hadeeth). That is why it was made contingent upon Allah's will, because it is a statement, not a supplication. It is similar to what the Prophet, sallallaahu ‘alayhi wa sallam, used to say when he visited a graveyard, "As-salaamu ‘alaykum ahla Ad-Diyaari min Al-Mu'mineena wal-Muslimeen, wa inna in shaa' Allahu bikum laahiqoon..." (Which means: Peace be upon you, inhabitants of the dwellings, believers and Muslims, if Allah wills we will join you.) [Muslim]
The wording and context of the hadeeth clarify this meaning. Ibn ‘Abbaas narrated that the Prophet, sallallaahu ‘alayhi wa sallam, visited a sick Bedouin man and said to him, "Do not worry, Tahoor (i.e. your illness will purge your sins), if Allah wills." The Bedouin said, "Tahoor! No it is not so; rather, it is a fever that is burning in the body of an old man and it will make him visit his grave." The Prophet, sallallaahu ‘alayhi wa sallam, said, "Then it is so."
The following lines will shed light on the statements of some scholars in this regard.
Al-Mulla ‘Ali Al-Qaari said, "He said, 'if Allah wills,' to seek blessing or to resign the affair to Allah, or to make it contingent upon the will of Allah..." [Mirqaat Al-Mafaateeh Sharh Mishkaat Al-Masaabeeh]
Al-Kooraani said, "The words 'Tahoor, if Allah wills' in the hadeeth reflect optimism and a consolation for the sick person. He made it contingent on the will of Allah because he had no knowledge of the consequences (of that illness)." [Al-Kawthar Al-Jaari Sharh Saheeh Al-Bukhaari]
Shaykh Ibn ‘Uthaymeen said:
"The Prophet, sallallaahu ‘alayhi wa sallam, said, 'if Allah wills' because this is a statement and not a supplication. The person should be firm in supplicating (i.e. confident that Allah will answer him as He promised) and not add, 'if Allah wills' to the supplication. This is why the Prophet, sallallaahu ‘alayhi wa sallam, forbade saying, 'O Allah, forgive me if You will, have mercy on me if You will...' It is only said to someone who can be compelled into doing something against his will or who perceives answering the request as a great matter... The Prophet, sallallaahu ‘alayhi wa sallam, said, 'Tahoor, if Allah wills' because it is a statement, and as a good omen..." [Sharh Riyaadh As-Saaliheen]
‘Abd Al-Kareem Al-Khudhayr said:
"If the supplication is phrased in the imperative mood, such as, 'O Allah, forgive me, have mercy on me, forgive so-and-so', then it is impermissible to tie this to the will of Allah, as it was prohibited (in the Sunnah of the Prophet, sallallaahu ‘alayhi wa sallam). But in the form of a statement, one may say, 'If Allah wills' even if the meaning of the statement implies that it is a supplication, such by as saying, 'Allah will forgive you if Allah wills' and 'Allah will reward you if Allah wills'. This is because the Prophet, sallallaahu ‘alayhi wa sallam, said, 'Tahoor, if Allah wills', and he said (when breaking his fast), 'Thirst has gone, the arteries are moist, and the reward is sure, if Allah wills.' There is no harm in saying, 'If Allah wills' in what is similar to this as long as it is in the form of a statement and not a request in the imperative mood." [Sharh Sunan At-Tirmithi]
Allah knows best.
You can search for fatwa through many choices