This statement in general is based on our observation and experimentation. This world (the material world), for the most part, works on the principle of ‘cause and effect‘, where every effect has a cause behind it, e.g. one works hard and one will succeed. However, experience also tells us that this is not always the case as we see exceptions to this rule as well. Therefore, it is a statement of general observation. And since Allah is the creator of worldly principles as well (including but not limited to ‘cause and effect‘), so we attribute such things to Allah as an extension of our belief since He ultimately controls everything. Therefore, the right approach in this regard in the light of Quran would be that if one is successful after hardwork, it is with Allah’z izn ofcourse, and if one is not successful even after hardwork, then is also in accordance with Allah’s scheme of tests and trial instituted in this world.
In the Quran also, we find certain acts being attributed to God; however, the real objective in this regard is not the attribution of these acts, it is their attribution to certain laws and principles on the basis of which these acts materialize. Because these laws and principles have been set by the Almighty, He has attributed the acts which emanate on the basis of these laws and principles to Himself at certain places in the Quran. For example, فَلَمَّا زَاغُوا أَزَاغَ اللَّهُ قُلُوبَهُمْ (٥:٦١) (And when they deviated [from the truth], God led away their hearts [from the truth], (61:5)) and وَنُقَلِّبُ أَفْئِدَتَهُمْ وَأَبْصَارَهُمْ (١١٠:٦) (We will turn away their hearts and eyes [from the truth], (6:110)). On such instances, the Quran also refers to the principle on the basis of which a certain act emanates. For example, words such as: “God only leads astray the defiant.”
These insinuations are meant to direct the attention of the reader on the factual reality so that the apparent meaning of the words does not create any misconception in his mind.