It's an inversion in an unreal conditional sentence. You often see it in formal contexts.
Without an inversion, the sentence would be 'If I had known what was going to happen, I would have prepared for that.'
اگه میدونستم قراره چی بشه، براش آماده میشدم.
Did the speaker really know what would happen? No.
Is he imagining if the situation were different? Yes.
What is the imaginary condition? If he had known what was going to happen (but in real life he didn't know what was going to happen)
What is the imaginary result? He would have prepared for that (but in real life he wasn't prepared)