Praise be to Allah.
This hadith was narrated by Muslim in his Saheeh (751) from ‘Aa’ishah, who said: One night I noticed that the Messenger of Allah (peace and blessings of Allaah be upon him) was not in his bed, so I reached out looking for him, and my hand touched the soles of his feet; he was in his prayer place and his feet were upright (i.e., he was prostrating), and he was saying, ‘Allahumma a‘oodhu bi ridaaka min sakhatika wa bi mu‘aafaatika min ‘aqoobatika wa a‘oodhu bika minka. Laa uhsi thanaa’an ‘alayka anta kamaa athnayta ‘ala nafsika (O Allah, I seek refuge in Your pleasure from Your wrath, and I seek refuge in Your protection (against sin) from Your punishment. I seek refuge in You from You. I cannot enumerate Your praise, You are as You have praised Yourself).’”
Al-Munaawi (may Allah have mercy on him) said: “wa a‘oodhu bika minka (I seek refuge in You from You)” means: I seek refuge in Your mercy from Your punishment, for what he sought refuge from stemmed from His will and His creation, by His leave and His decree. For He is the One Who is the cause of all causes, in terms of creating and bringing into existence, and he is the One Who grants refuge from them and wards off their evil and harm. End quote from Fayd al-Qadeer Sharh al-Jaami‘ as-Sagheer (2/176).
Ibn al-Qayyim (may Allah have mercy on him) said: “wa a‘oodhu bika minka (I seek refuge in You from You)” refers to seeking refuge in the divine attribute of pleasure from the divine attribute of wrath, and in Allah’s protection (against falling into sin) from His punishment; thus it is seeking refuge in Him from Him on two counts. It is as if, when the worshipper seeks refuge in Him from Him, he is referring to what he has mentioned in the two previous sentences, for seeking refuge in Him from Him refers to the words that came before it. Moreover, this points to a great meaning, which is attaining perfect Tawheed, and acknowledging that what the individual is seeking refuge in and fleeing from is in fact the action, will and decree of Allah, for it is He alone Who has the control and decree; if He wills harm to befall someone, no one could protect him from it except Him, for He is the One Who willed something that could harm him, and He is the One Who willed the warding off of that harm from him. Thus Allah becomes the one with whom and from whom refuge is sought on the count of the two wills. “If Allah afflicts you with harm, none can remove it but He” [al-An‘aam 6:17]. Thus it is He Who afflicts people with calamity and it is He Who relieves them of it; there is no god worthy of worship except Him, so there is no fleeing from Him except to Him, and there is no seeking refuge from Him except in Him, for there is no Lord besides Him and no one who controls people’s affairs except Him; He is the One Who controls man and directs him however He wills.
End quote from Tareeq al-Hijratayn wa Baab as-Sa‘aadatayn (1/431).
And Allah knows best.