- das Haus = the house
- zu Hause = at home
- nach Hause = (to) home
The latter are exceptions, fixed expressions. If you look up your dictionary, you won't even find the gender for the word "Hause" because it does not exist as a standalone word. If just talking about home in general, you use words like "das Zuhause" or "das Heim".
'Hause' is archaic German, hence being no longer used as a word except in some fixed expressions. I think it's a relic of a mostly obsolete part of the dative case, which affixes an -e to the end of some singular nouns. This can also be seen in the motto "Dem Deutschen Volke" (which means "to the German people"), and expressions "am Tage" (during the day), "auf dem Lande" (in the country).
At this point I wouldn't stress about them, and as @EeroK said, they're an exception. Just know when to recognise it in expressions.
Further reading if you're still confused: http://forum.wordreference.com/threads/haus-vs-hause.1574076/
Hope this helped!
"Er war vorher heim" is not a german sentence. What you could do is "Er war vorher daheim", since "daheim" and "zu Hause" are basically interchangeable. But "zu Hause" is way more common than "daheim". The term "Heim" is nowadays mostly used in fixed expressions like "Heim und Herd" (~Home and stove) (which is also archaic) or in terms like "Kinderheim" (children's home) or "Altenheim" (retirement home) where it's supposed to mean "home" but is more or less interpreted as "asylum", to be frank.
i.e. "before something else happened" -- the "something else" is not mentioned in this sentence but would be clear from context.
For example, Gestern abend war er im Konzert, aber vorher war er zu Hause. "Last night, he was at the concert, but previously/before that, he was at home."
No, they are not the same - im Haus "in the house" just refers to being in a building that you had spoken about before or that is obvious from context; zu Hause "at home" is in the place where you feel comfortable (which need not even be a house: it could be an apartment or even underneath a bridge).
I agree! "Beforehand, he was at home." "He was beforehand at home." Beforehand is an adverb and modifies a verb, so how can its placement next to a verb be wrong? It doesn't seem grammatically incorrect to me and could be viable with commas, emphasis, and appropriate phrasing in spoken English. This sentence needs context. If I asked you "where was he?" you would say "He was at home." "And beforehand?" "He was, beforehand, at school." At better example "Your exams are coming. You need to study beforehand" ( in advance).
I translated "he was earlier at home". I got zapped and corrected with "he was formerly at home" which nobody would use in English unless I am trying to say something like "he was formerly at home when out at sea" or something similar. When I wanted to discuss that, Duolingo cheated and translated here with "he was PREVIOUSLY at home" which is correct and acceptable.