Are you confusing どういうつもり with どうするつもり / 何するつもり, maybe? どういうつもり is asking the addressee's intention of why they did, i.e., "What's the meaning?". Thus, こんなことしてどういうつもり!? means "What does he mean by doing such a thing?" (So, "Why would he do such a thing?!" is not wrong in the end.)