With each key on the piano (ABCDEFG) you can construct a scale. So the E major scale, E# major scale, E minor scale, etc. Then in a specific scale you construct chords as well.
This sounds like you're talking about the idea of a song being in a key, which is defined by the root note (e.g. E) and a type of scale (major or minor).
When someone says play the Em7 for example, how do you know which scale to play the Em7 chord in?
That question doesn't make much sense to me. It's a bit like asking "when someone says a word, how do you know what they're talking about?". (I'm not saying this as a criticism - just in the hope that it will make things clearer!)
When you play a single chord, you don't have to know what scale to play it in (or what 'key' to play it in) - just like it's possible to say a word without knowing what topic you're talking about.
However, if you hear someone play the E minor 7th chord, it is possible to guess what key they are playing in. Because that chord contains E, G, B, and D, it might be that they're playing in a key with those notes in:
C Major / A minor
G Major / E minor
D Major / B minor
It might not be that they're playing in those keys, because it's possible to use notes in a song that are outside 'the key it's in'. But those are good guesses.