This is one of those topics, like almost all of them, where you find the basic rules you learned don't cover all the subtleties. These are both correct with subtle differences in meaning that I don't think make much difference in this case. If I explain it, I'll probably be wrong so we should wait for the experts. But I'll say, that I would normally add a silent (は) to help tease the difference in meaning.
日本に(は)一番高い建物は何ですか
Here we get IN Japan.
日本で(は)一番高い建物は何ですか
Here we get As for Japan.
This example is difficult to differentiate but consider
東京に(は)一番美味しいレストランは何ですか
Here, I feel like the question is what is the best restaurant IN Tokyo (within its boundaries).
東京で(は)一番美味しいレストランは何ですか
Whereas here, I feel like the answer could be some place on the other side of the Edo River that's technically in Chiba but close enough to say Tokyo.
But I could be totally off base here. Let's see what the experts say.