The first thing I should probably mention is that our cognition tends to be biased in favour of seeing things as caused by a rational agent, and this leads us to think disproportionatey often about agents who might be responsible for what we see. To put it another way: we tend to look for someone behind the curtain. The puppet master, the playmaker or other deity.
This is why we think about gods, and ghosts, and other supernatural beings -- but it also leads us to misattribute the causes of events in many cases. We are especially prone to this when we see a patterned regularity in an occurrence which implies causation by some agent.
For example, we see that the sun rises every day and we think: 'The sun causes the day' -- but of course actually it is the earth's rotation which causes the day. This misconception can be called 'the intentional stance', or more properly because it is not a fallacy if you are justified in thinking that there might be an agent responsible for what you see, then: agent causation.
This is important because the human mode of cognition, which was evolved to see patterns in nature that imply causation by agents -- tends to lead us into thinking about the causes of actions as being intentional.
In the case of gratitude, we tend to think that an agent has acted with intention because the action was intentional. But this isn’t quite true. Actions can be performed without any real intention -- and in fact most actions are not performed intentionally.
We tend to assume that actions are performed intentionally, but the reality is that we do not know if an action was intentional or not. It could have been unintentional -- and in fact most actions are accidental.