It is argued that Qur’an contradicts itself when it says to forgive on one hand (45:14) while it says that revenge is allowed (9:29). It is argued that the circumstances of Prophet Muhammad (ﷺ) determined the themes of revelation.
Even though the author of the allegation, provides the reason, he still rejects it based on his own desires. Here is the explanation from Ibn Kathir:
﴿قُل لِّلَّذِينَ ءَامَنُواْ يَغْفِرُواْ لِلَّذِينَ لاَ يَرْجُونَ أَيَّامَ اللَّهِ﴾
(Say to the believers to forgive those who hope not for the Days of Allah,) means, let the believers forgive the disbelievers and endure the harm that they direct against them. In the beginning of Islam, Muslims were ordered to observe patience in the face of the oppression of the idolators and the People of the Scriptures so that their hearts may incline towards Islam. However, when the disbelievers persisted in stubbornness, Allah legislated for the believers to fight in Jihad. Statements of this meaning were collected from `Abdullah bin `Abbas and Qatadah. Mujahid said about Allah’s statement,
﴿لاَ يَرْجُونَ أَيَّامَ اللَّهِ﴾
(those who hope not for the Days of Allah,) “They do not appreciate Allah’s favors.” Allah said,
﴿لِيَجْزِىَ قَوْماً بِمَا كَانُواْ يَكْسِبُونَ﴾
(that He may recompense people, according to what they have earned.) meaning, if the believers forgive the disbelievers in this life, Allah will still punish the disbelievers for their evil in the Hereafter. Allah’s statement next,
﴿مَنْ عَمِلَ صَـلِحاً فَلِنَفْسِهِ وَمَنْ أَسَآءَ فَعَلَيْهَا ثُمَّ إِلَى رَبِّكُمْ تُرْجَعُونَ ﴾
(Whosoever does a good deed, it is for himself, and whosoever does evil, it is against (himself). Then to your Lord you will be made to return.) meaning, you will all return to Allah on the Day of Resurrection, when you and your actions will be displayed before Him. Then, He will recompense you for your deeds, good for good and evil for evil.
According to scholars, when a verse is abrogated, the abrogated verse ceases to carry the original meaning of the context derived from the situation in which it was revealed but it does not become completely meaningless. It carries the meaning defined in the text. The following verse explains the alleged contradiction:
ان تبدوا خيرا او تخفوه او تعفوا عن سوء فان الله كان عفوا قديرا
If [instead] you show [some] good or conceal it or pardon an offense – indeed, Allah is ever Pardoning and Competent.
Moreover in Qur’an 2:178 and 5:45, we find that an equal punishment in return is allowed but forgiveness is better.
Indeed, Allah knows the best.
 Qur’an 4:149