'Before' is a preposition, and sometimes an adverb.
'Beforehand' is always an adverb.
You should have told us about this problem beforehand. (adverb)
You should have told us about this problem before take-off (preposition)
The relationship between 'before' and 'beforehand' is the same as between 'after' (a preposition) and 'afterwards' (an adverb).
We can talk about this afterwards.
We can talk about this after dinner.