We use final clauses (Finalsätze) when we want to explain the purpose or goal behind an action — answering the question "why?" German has two tools for this job, and choosing between them isn't arbitrary: it depends on one simple, decisive rule.
The first tool, um...zu, is used only when the person performing the main action is the same person who achieves the goal. In that case, you don't repeat the subject or conjugate a second verb — instead you use an infinitive after zu at the end of the clause: Ich lerne Deutsch, um in Deutschland zu arbeiten (the same person, ich, both learns and works). Notice that zu comes directly before the verb, and zu + verb stay together at the very end.
The second tool, damit, is used when the subject of the goal is a different person from the subject of the main clause. Here you need a full subordinate clause with its own subject and a conjugated verb, which — as usual in subordinate clauses — moves to the end: Ich spreche langsam, damit du mich verstehst (I am the one speaking, but you are the one who understands — two different subjects: ich and du).
The core distinction is simple: um...zu contains no subject and no conjugated verb, only zu + infinitive. Damit contains a full subject and a fully conjugated verb, exactly like any other subordinate clause with weil or dass. This resembles the idea of "in order to" that many languages express with a single fixed expression regardless of who the doer is — German instead forces a structurally different sentence depending on whose goal it is.
The most common mistake is using damit even when the subject stays the same, producing incorrect sentences like damit ich Deutsch zu lernen — a double error, since damit doesn't take zu at all, only a full conjugated verb. The rule of thumb to remember: always ask yourself who achieves the goal? If it's the same person as the main clause, use um...zu. If it's someone else, use damit with its own subject and conjugated verb.