What does this sentence mean?
What a fool I was to do it!
I think it means either of them below according to context.
1.I was a fool that I was going to do it!
2.I was a fool that I did it!
Your recastings are not idiomatic
What a fool I was to do it
is a very emphatic way to say
I was a fool to do it
or
I was foolish to do it
or
It was foolish of me to do it.
All are simply admissions of having done something foolish.
The second one is correct in the past tense, the infinite phase does not affect the tense.
Present:
"What a fool I am to do it since I know he's lying."
Future:
"What a fool I'll be to do it if he continues to lie."