In your examples before is not a preposition, it is a linker introducing a time clause. Time clauses can refer to several "times":
To the past:
I wrote a letter before I left the office. (First I wrote the letter, then I left)
To the future:
I'll write a letter before I leave the office (First I'll write the letter, then I'll leave"
But your second example is a mixture. "I wrote a letter before I leave the office" The first part speaks about the future ( I wrote) and the second seems to refer to the future (before I leave), so it makes no sense.
I hope this helps.