The second sentence with "Had" at the beginning is an example of subject/verb inversion.
In older English certain verbs like, should, had, could, would, were, did, know, etc. expressed condition when the verb was placed before the subject. Appropriately, they are called inverted conditionals.
-Knew I the road….meaning…….If I knew the road.
-Would he but try…meaning ……If he would only try.
-Did space allow…meaning ......If there were space.
The only inverted conditionals still in contemporary usage are should, had, and were.
Why have they survived? I suppose it is because they are brief and elegant, and useful.
They can be used in formal language:
-Were it not for Spiderman, the city would have been destroyed.
…...is classier than...
-If it were not for Spiderman, the city would have been destroyed.
-Should I be elected….
……sounds more impressive than…
-If I should be elected….
They can be used in everyday language:
-Should someone drop by…
…..is easy to understand , to the point and shorter than…
-If someone should drop by….
When you are in the middle of a conversation, setting up the whole "if clause construction" takes more effort. Often the inverted form just flows better with the conversation.
--Blah, blah, blah, ....well, had I not done it, we would've lost…..blah, blah, blah, etc.