Fundamental Principle of Fiqh #1
"The matters are according to their purposes."الأمور بمقاصدها
Based on the prophet's Hadith, "Deeds are according to the intention." This principle of fiqh (jurisprudence) has a bigger scope than the Hadith which is limited to deeds only.
There are up to 70 subjects of fiqh under the Hadith and many scholars consider it to be equivalent to a third or half of knowledge since it deals with the intention while all other fields deal with the actions.
Here's an example of how to apply this principle. If someone leaves a container to collect rainwater and another person takes the water, the principle dictates that the owner of the container has the right to the water only if the original intended purpose of leaving the container outside was to collect water. Another implication is that anything done under force or pressure is invalid.
In the matter of worship there are cases where one intention could serve more than one action or vice versa. However, these should be studied on a case by case basis so as to avoid nullifying an obligatory deed.