The question is really, "why is 'ago' at the back?" It's one of the very few postpositions that English has. ("notwithstanding" is another one, though that can also come before a noun - "notwithstanding his dislike of the war = his dislike of the war notwithstanding, ....")
We have "for five years", "in five years", "by tomorrow", "on Tuesday", "during the week", all with prepositions... but "five years ago" rather than "before five years" the way (say) German does it.
Esperanto uses a preposition here, which seems unremarkable to me.
For me, "five years ago" and "five years before" do not mean the same thing - "five years ago" means "five years before the present moment" while "five years before = five years previously = five years before the moment we are talking about (which is often in the past)".
And "before five years" doesn't work for me on its own at all; I'd have to expand it to "before five years had passed" or "before five years were up" or "before five years had elapsed" or some other phrase with a verb in it.