I don't understand "Have had"
Solution 1:
The first sentence is incorrect. The second is correct but it would be more idiomatic to say "If you had done (something) this would never have happened".
The first "have" in "have had" is used as an auxiliary: it's a necessary part of how you indicate the tense, and doesn't have its own meaning beyond that.
So for example:
I eat an apple -> I would have eaten an apple if I were hungry
But "have" is also a verb in its own right. It also has other grammatical and semantic uses, like in the construction "have to" or ready-made expressions like "have a baby". In a context that already uses "have" in that way, how do we form the tense? Do we just have two "haves"? That would be stupid!
In any case it's what we do:
I have a cold -> I would have had a cold if I'd spent too much time outside
I have to break into Fort Knox -> I would have had to break into Fort Knox if the princess had been imprisoned there
You can't really avoid it; "I would have a cold" or "I would have to break in Fort Knox" is a different tense, equivalent to "I would eat an apple", not "I would have eaten an apple".
In the case of your sentence, the verb is "happen", not "have happen", so the only "have" involved is the auxiliary. No need for anything more exotic.
Actually "have happen" is a construction that exists, for example in "X had Y happen to them"; it's like "Y happened to X" but emphasizes X's passivity more I guess. If that's what we were using you would indeed have "have had":
I have this happen to me -> I would have had this happen to me if I hadn't been careful.