Allah stated that He will punish the hypocrites for their mockery, using the same terms to describe both the deed and its punishment, although the meaning is different. Similarly, Allah said,
﴿وَجَزَآءُ سَيِّئَةٍ سَيِّئَةٌ مِّثْلُهَا فَمَنْ عَفَا وَأَصْلَحَ فَأَجْرُهُ عَلَى اللَّهِ﴾
(The recompense for an offense is an offense equal to it; but whoever forgives and makes reconciliation, his reward is with Allah) (42:40), and,
﴿فَمَنِ اعْتَدَى عَلَيْكُمْ فَاعْتَدُواْ عَلَيْهِ﴾
(Then whoever transgresses (the prohibition) against you, transgress likewise against him) (2:194).
The first act is an act of injustice, while the second act is an act of justice. So both actions carry the same name, while being different in reality. This is how the scholars explain deceit, cunning and mocking when attributed to Allah in the Qur'an. Surely, Allah exacts revenge for certain evil acts with a punishment that is similar in nature to the act itself. We should affirm here that Allah does not do these things out of joyful play, according to the consensus of the scholars, but as a just form of punishment for certain evil acts.