As all the others have said, you made a bad call on the flop but then you hit your card on the turn and you just checked, i know that by betting you could have scared him of the hand, but a bet of 5 dollars, for example, smells of weakness and sometimes players will go over the top when you make a bet like that. You have to thank the poker gods because it all turned out ok because you nailed an ok pot on that hand.
-anto