Keys are a concept based on the idea of setting up a specific tone (tonic) as the point of final rest in a piece of music. Once Harmony was introduced and became the most important tool for setting up and supporting a tonic. this idea developed into two keys – major and minor. Within the major and minor key system, music that sets up and supports a major chord on the tonic is in the major key and music that sets up and supports a minor chord on the tonic is in the minor key. The scale that might be used to do this does not matter. The entire chromatic scale can be used so long as there is a clear sense of tonic resolution.
The relation of the major and minor keys to the common major and minor scales is only due to those four scales being the most often used tools for setting up and supporting the major and minor tonalities. That’s right… I wrote four scales. Most people who poke around at this stuff and ask the same question you’re asking are unaware that the minor key is commonly drawn from three different scales – natural minor, harmonic minor and melodic minor.
Those scales do not determine the keys. They are only used to help establish the sound/color of the key. In some cases they are used only for the fact that they don’t ruin the key.
Now, this idea of keys was developed to analyze and categorize music written in the 17th and 19th centuries, but we still hang on to it today. That period, by the way, is what is called the “Common Practice Period”. Most general theory of harmony is concerned with describing what happened through that period. That doesn’t mean that things didn’t exist prior to or after that period. It usually just means that a more specialized theory is often used to describe music from that period.
The concept of keys was slowly developing from the modal system established in the church through the renaissance period. It didn’t just appear one day in the 1600s and everybody started using it. It’s just that, in the Common Practice Period, it’s clear that keys were the overriding factor that influenced harmony. Once the 20th century rolled around, you had everybody and their dog trying to destroy the sense of keys. Many people today try to use keys to analyze and categorize modern pop music. But modern pop music doesn’t have a sense of needing to rigidly define a tonic.
An example of this would be the modern use of Mixolydian based ideas for establishing major key songs, or borrowing heavily from blues song structure to include a lot of parallel minor key chords and riffs into the major key.
So, when modes are being used, in the modern sense, they are still being used to set up major and minor key music. The use of a mode doesn’t change that. The modes only give different colors to work with, so to speak.