I don't understand why you're able to interchange これ in 「これはペンです」and 「ペンはこれです」, but you can't interchange ここ in 「まどはここです」 and 「ここはまどです」
Your assumption is not correct. In both pairs, the two sentences are not interchangeable. は is called a topic marker. Basically, it marks what you're talking about. Changing the topic of a sentence will usually change the "feeling" of the sentence drastically.
これはペンです and ペンはこれです are both grammatical, but are not interchangeable. The following two sentences are very different in meaning.
- これはペンです。 (This thing? This is a pen.)
- ペンはこれです。 (Looking for a pen? Here, this is the pen, here you go.)
Likewise, まどはここです and ここはまどです are both grammatical, but are not interchangeable. The following two sentences are very different in meaning.
- ここはまどです。 (Curious about this structure? This is a window.)
- まどはここです。 (Looking for a window? Here it is.)
I think it's because of the topic particle. In your first sentence,「これ」 and 「ペン」refer to the same thing. While「ここ」refers to a place; the subject is「まど」.