And why did you, when you entered your garden, not say, 'What Allāh willed [has occurred]; there is no power except in Allāh'? Although you see me less than you in wealth and children,
Allah tells us how the rich man's believing companion replied to him, warning and rebuking him for his disbelief in Allah and allowing himself to be deceived.
أَكَفَرْتَ بِالَّذِى خَلَقَكَ مِن تُرَابٍ
(Do you disbelieve in Him Who created you out of dust...) This is a denunciation, pointing out the seriousness of his rejection of his Lord Who created and formed man out of dust -- that is, refering to Adam -- then made his offspring from despised liquid, as Allah says:
(How can you disbelieve in Allah Seeing that you were dead and He gave you life) 2:28 meaning, how can you reject your Lord and His clear signs to you, which every one recognizes in himself, for there is no one among His creatures who does not know that he was nothing, then he came to be, and his existence is not due to himself or any other creature. He knows that his existence is due to his Creator, beside Whom there is no other god, the Creator of all things. So the believer said:
The word: ثَمَرٌ (thamar) in: وَكَانَ لَهُ ثَمَرٌ (And he had wealth - 34) means the fruit of trees as well as wealth, in an absolute sense. At this place, Sayyidna Ibn ` Abbas ؓ ، Mujahid and Qatadah have taken it in the later sense (Ibn Kathir) According to the Lexicon, al-Qamus, this word is used to denote the fruit of the tree and wealth of all kinds. This tells us that not only did he own gardens and farms, he also had gold, silver and other luxuries. Even his words reported by the Qur'an: (I am greater than you in wealth -34) also express the same sense. (Ibn Kathir)
About the statement: مَا شآء اللہ لا قُوَۃَ اِلَّا بِاللہِ : "[ Everything is ] as Allah wills. There is no power except with Allah," it has been reported in Shu'ab al-'Iman on the authority of Sayyidna Anas ؓ that the Holy Prophet ﷺ said, "whoever sees something, likes it - and says 'masha'Allahu la quwwata illa bil-lah' - nothing will harm it (that is, what he likes will stay protected).' And it appears in other reports, 'whoever recites this kalimah when he likes something he sees, it will stay protected against the evil eye.'
Take the example of a lush green garden which, due to a sudden natural calamity, is completely destroyed. This, figuratively speaking, will be the fate of one who achieves wealth and position in this world and becomes proud as a result. Whatever share of wealth and position a man receives in this world is, in fact, a test from God. But an unjust and transgressing man takes it to be the result of his own efforts. Consequently he develops an attitude of arrogance. He looks down upon a person whose share of wealth and position in this world is comparatively inferior. He develops a certain type of mindset by which he thinks that his world will never come to an end, and that even if this world ends and another world comes into existence, there is no reason why he should not enjoy the same comfortable conditions as he is enjoying here. He fails to differentiate between the world of trial and the world of reward.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.