"Two years ago" means two years from the current date, meaning, two years from right now.
"Two years before" is incomplete. You need something after the "before" to specify what it happened before.
Examples:
"I moved out two years before the divorce."
"His heart stopped beating two years before I married."
"I lost my sandwich two years ago."
"My cat locked himself in the closed two years ago."