Yes, they're the same. They can be used either when politely declining an offer, or when thanking someone profusely for something (when reiterating how grateful you are, and maybe they're shrugging it off like it's no big deal, for example). You can always use "thank you".