Motivation is paramount. Doing good is a privledge.
If the unique-to-him and variable precepts that drive the activity in an atheist are other-inspired and not divinely inspired, then it is predictable that on occasion the activity will not be oriented toward a good even though that is the object and seems apparent. One cannot receive aid for discernment from a being one doesn’t believe exists. It is guaranteed this will occur because the receiver of such a good is always the owner of it and that is God. All divinely inspired good finds it’s destination to God, as such good is a gift to God for His glorification.
One does not offer a gift to a being one does not believe exists. The motive negates the effect, and the activity could only serve a temporal end and cause a random effect in this world. Possibly he gains credit from man for it, but cannot gain credit from the Being that is the owner.
The Church goer has laid his intent on the table for all to see, and bares himself to redicule. He has entered into covenant with the Holy Spirit knowing the odds and taking the risks that that entails inspite of his concern being a sinner. In trust, His act acknowledges the existance of a God and makes him accountable to Him, offering himself to whatever may arise because of his activity. The sins he commits carries with it the extra burden of a promise he made and now broken. God recognizes and blesses the Church goer, the one that formally promised to try to please Him in his activity and gives him extra graces to help him keep those promises.