If you remove the last 'I thought' you get a contradiction. Consider the central phrase, "The thought I thought wasn't the thought I thought." Replacing all instances of 'thought' with a different noun and verb we get, "The car I drive wasn't the car I drove." If we put the 'I thought' back into our car/drove example we get, "The car I drove wasn't the car I thought I drove."
This grammatical word play is possible with any words that have can be taken as multiple parts of speech, especially noun/verb. An example from a book of puzzles I have asks: "Who could make the following statement? 'We eat what we can and can what we can't.'" The answer is a farmer or a fisherman.
During a meeting at the [fictional] local diet club, the chairperson exclaimed, "We have to fast, FAST!"
I'm not aware of any official name for these kinds of wordplay.