"Why did you do that?"
Translation:Γιατί το έκανες εκείνο;
It is is supposed that that is translated as εκείνο. But it is not good Greek to say Γιατί (το) εκανες εκείνο. Εκείνο is something which is not so close in space or time as it is αυτό. The reverse translation to why did you do that could be γιατί το έκανες, or γιατι έκανες αυτό ( implied not doing another option), γιατί το έκανες αυτό (το here is not an article but put to emphasize αυτό).
You can use the pronoun αυτός in two different ways.
You use it individually. You're going to refer to something: αυτός (he); αυτή (she) if you refer to people - αυτό (it/this) if you refer to animals or things.
You use it as an adjective (this). You put it next to a noun. For example: το μήλο (the apple) becomes αυτό το μήλο (this apple). In this case, however, you always need to let the original article (in the example το) be. You cannot say αυτό μήλο.
In the sentence given, 'Γιατί το έκανες αυτό;' this is exactly what happens. Although it seems as if you use αυτό individually, you need to think 'Why did you do this thing?' Although the noun is hidden, you have to think it's there...
So, we have the second case here. I hope that makes things clear.