In the following dialogue, is the preposition necessary, assuming "where" is equal to a preposition plus a noun denoting a place.
A: Where did he go last week?
B: To Japan.
No, it isn't necessary. Saying "Japan" would be equally acceptable.
The answer to a question can be a fragment of almost any length, as long as it contains the necessary information, forms a contiguous piece of a grammatical sentence, and doesn't repeat part of the question.
In particular, some question words, including "where", imply a preposition, making the preposition optional, but allowed, in the answer. Both of your sentences are correct.