This is a very interesting question. Here is my analysis.
When the verb かかる is used to talk about an amount of time spent (or to be spent) before some event happened (or happens), as in your example, it is used with [event]-までに.
けがが治るまでに3週間かかった。
In this case, the verb itself doesn’t refer to a continuous action or state. It simply means “take” or “require”, which in Japanese is apparently not considered something that, well, takes time. In your example, that (“taking” of three weeks) happened before the healing of the injury. Hence までに.
However, the same verb can also be used with まで as in the following example.
けがを治すのに4月までかかった。
Here, the verb is used to talk about a continuous effort, and まで is used not with an event but with a specific point of time. The effort continued till that point of time. Hence まで.