Purpose ("in order to")
Cause/Reason ("because of, due to")
The structure ために has two major uses: expressing purpose ("in order to," "for the sake of") and expressing cause/reason ("because of," "due to"). Understanding which meaning is intended depends on the form of the word before ために and the context.
When expressing purpose, ために follows a verb in the dictionary (non-past) form or a noun + の. The subject of both clauses is typically the same, and the main clause describes a volitional action – something the speaker deliberately does to achieve the goal.
The verb before ために must be in the dictionary form (not past tense) when expressing purpose. If you see a past-tense verb before ために, it signals a cause/reason reading instead.
When expressing cause or reason, ために can follow a verb in any plain form (including past tense), a noun + の, an い-adjective, or a な-adjective + な. Unlike the purpose usage, the subjects of the two clauses can be different, and the result in the main clause is often unintentional or beyond the speaker's control.
The cause/reason usage tends to appear more in written or formal contexts. In casual spoken Japanese, から or ので are more common for expressing reasons.
A few clues help determine which meaning is intended: