'Why did you do that' refers to something specific which happened in the past, like stealing someones newspaper, while 'Why would you do that' is hypothetical, so it didn't necessarily happen. They can both be used interchangeably, but I would say that 'why did' is more direct than 'why would'.