ドアの鍵は「the key of the door」?それとも「the key to the door」?

「of」は「一部分」を表すときに使う
前置詞「of」は「一部分、部品」を表す時に用いられます。
The handle of the mug is broken off.
(マグカップの取っ手が取れた)

「取っ手(handle)」は「マグカップ(mug)」の一部分です。
もう一つ、例文を見てみましょう。
The peak of the mountain is covered with snow.
(山頂部分は雪で覆われています)

スケールは変わっても、考え方は同じですね。「山頂(peak)」は「山(mountain)」の一部分です。
こうして、「全体の一部分」を「of」を使い、「一部分 of 全体」で表現します。
もちろん、「handle(取っ手)」は「ドアの一部分」です。そのため、「the handle of the door」です。
しかしながら、「鍵」は違います。鍵はドアに「合わせる、ピタリとくっ付けるもの」です。一部分ではありません。あくまで、外付けのアイテム、と考えます。
そのため、「of」ではない前置詞を使う必要があります。
付属する感覚の「to」
そしてこの場合、使う前置詞は「to」になります。
「to」はよく、「到着」の時に使いますね。
よくあるのが、「go to school」などです。
I always go to school with my sister.
(私はいつも姉と一緒に学校に行く)

このように「ピタリと学校に到着しているイメージ」が「to」の感覚です。
もう一つ例を挙げましょう。
I gave a present to my mother.
(私は母にプレゼントをあげた)

同じですね。「give 物 to 人」で「人に物を渡す」意味ですが、ピタリとくっつく感じが「to」です。
どうでしょうか。構図的に「to」になってくるのが、分かると思います。
こうして、「ドアにピタリと合わせる、くっ付ける」感覚から「to」を用い、ドアの鍵は「the key to the door」で表現します(よく「付属のto」と説明されます)
まとめます。
日本語で考えると、どちらも「ドアの取っ手」「ドアの鍵」となるので、ここは日本語にない感覚です。学校でもほぼ習わないので、「大人のやり直し英語」によく出てきます。
その他の「付属のto」の例文
その他にも、この「付属のto」を使ったパターンがあるので、以下一覧で紹介します。合わせて確認してみて下さい。
the solution to the problem
:その問題の解決方法

Ex) Do you know the solution to this problem?
(あなたは問題の解決方法を知っていますか?)
the answer to the question
:その質問に対する答え

Ex) The answer to your question is no.
(その質問の答えは「NO」だ)
the key to success
:成功への鍵

Ex) Working hard is the key to success.
(ハードワークは成功への鍵だ)
the ambassador to the country
:その国の大使

Ex) I met the U.S. ambassador to Japan.
(私は駐日米国大使に会った)
be married to …
:(…と)結婚している

Ex) He’s married to my sister.
(彼は私の姉と結婚している)

be related to …
:(…と)血縁関係にある

Ex) They’re related to each other.
(彼らは血縁関係にある)
以上、「付属のto」のパターン一覧でした。