1. I visited the house where Tom lives.

2. I visited the house Tom lives.
3. I visited the house that Tom lives.
(Is #2 grammatical? Are they all right?)

4. Do you know the way how he got to the station?
5. Do you know the way that he got to the station?
6. Do you know the way he got to the station?
7. Do you know how he got to the station?
(#4 is ngrammatical. The others are grammatical? Am I right? Then Why is #4 ngrammatical?)

#1 is correct, but 2 and 3 are not.

#4 is incorrect; #5 is marginally correct.
The entire correct phrasing should be "Do you know the way by which he got to the station?" Neither 4 nor 5 fit.

#6 is OK, but #7 is by far the best!