If someone steals a previously stolen item from the thief is he guilty? Would it matter if he was stealing it only to return it to its original owner, or if the second thief was the original owner?
The g'mara in B'rachot 5b relates the story of R. Huna, who seemed to be being punished for something (his wine soured). It was suggested that he had failed to pay a share-holder, to which he replied that said person had stolen from him. They cite a proverb that "if you steal from a thief you also have a taste of it". The g'mara relates that he pledged to pay and his vinegar became wine again.
This seems to be a case of not only stealing from a thief but stealing one's own property back from a thief. So no, theft doesn't become ok if the target is a thief or the cause is just.
There is a concept of taking the law into your own hands. How it applies is debated. The Shulchan Aruch C.M. 4:1 would agree to your last case where a person is retrieving his own object. The Rema there brings other interpretations of the law.
It says the following in Mishneh Torah - Sefer Nezekim - Hilchot G'nivah - Halacha Bet:
אסור לגנוב כל שהוא, דין תורה. ואסור לגנוב דרך שחוק, או לגנוב על מנת להחזיר, או לגנוב על מנת לשלם: הכול אסור, שלא ירגיל עצמו בכך.
It is forbidden to steal at all, from the Torah. And it is forbidden to steal as a joke, or to steal in order to return, or to steal in order to pay: it is all forbidden, so that one shouldn't habitualize oneself to it.
The in Mishneh Torah - Sefer Nezekim - Hilchot G'nivah - Halacha Yud Zayin:
הגונב מאחר הגנב--אף על פי שנתייאשו הבעלים, אינו משלם תשלומי כפל; ואם טבח ומכר, אינו משלם תשלומי ארבעה וחמישה: לגנב הראשון אינו משלם, שהרי דין הבהמה הזאת לחזור בעיניה לבעלים ולא קניה הגנב; ולא לבעלים אינו חייב לשלם הכפל או ארבעה וחמישה, מפני שלא גנב מרשותן.
One who steals from a thief, even if the original owners have given up hope, he doesn't pay double payments; and if he slaughtered and sold, he doesn't pay the fourth and fifth payments: to the first thief he doesn't pay, because the ruling on a beast is to return it to it's original owner and not to the thief; and also to the original owners he doesn't have to pay double, the fourth or the fifth, since he didn't steal from them directly.
So it would seem that stealing from a thief is forbidden from the Torah, but at the same time does not carry the same penalties as stealing from the original owner.
If you are the original owner and you take it something back, then it doesn't seem to me that the concept of stealing could even apply, since it's your property in the first place.