"The key to/of the door"

English seems to have a preference for to or for when referring to an item for "operating" something. Hence:

the key to/for the door

the switch to/for the hall lights

the catch to/for the window

On the other hand, 'of' is used more when you're naming a component part of something; sometimes either 'of' or 'to/for' is possible, depending on whether you're just naming a part of something or implying its intended use:

the leg of the table

the door of/to/for the fridge

the ingredients of/to/for this soup

When identifying a part of something, English also permits other prepositions denoting location:

the handle on the fridge

the largest collection in the world

Various other languages tend to use the equivalent of 'of' in many of these cases: i.e. they have less of a distinction between naming the 'utility' vs 'existence' vs 'identification/location' of a component of something.