Both of the sentences above are translated as "J'ai du le faire".
BUT the two formulations in English have not-very-subtle differences in meaning.
"I had to..." implies "I was obligated to.." or "I was forced to..." - very definite!
"I must have..." implies "I may have forgotten to ..." -- quite indefinite!
How are these different flavors of meaning expressed en francais?