Because!
Not necessarily. It depends on the 'type' of DoW whether you get war happyness or not. Let me see if I can give you a short rundown on when and when you do not get any WH. (All the examples go the other way 'round too, except where noted.)
I'll start with the cases where the DoW'ed Civ
gets WH:
Sneak attacks. For example, an AI shows up somewhere in your empire and just attacks a city or so. (Other examples include the so-called sub-bug, or when an AI attacks on of your privateers in one of your harbors.)
Extortion. When an AI tries to extort something from you, you turn them down and they DoW.
Refusal to leave. When some AI shows up with a bunch of units in your territory and they decide to DoW after you've asked them to either "leave of declare."
Straight up DoW. The AI don't use it, but for the human player there is the possibilty to just click "Prepare for war" or whatever it says exactly, or to renegotiate peace and just close the diplo window without coming to an agreement.
Cases where the DoW'ed Civ
does not get any WH:
Espionage. An AI declares war on you after you've failed with an espionage mission. (Neither side gets WH.)
Military Alliances. Two AI forge an alliance against you, and one of them hadn't been at war with you yet.
Mutual Protection Pacts. You trigger an MPP by attacking some AI's units and as a result gain a new foe.
Nuclear Weapons. I am not entirely sure here, but when all civs declare war on you after you've used nukes I strongly suppose you won't get any WH from it. (This isn't something I see a lot.)
And lastly there is a case that is neither here nor there:
"Engineered" Wars. I just made up that name, but there exists the possiblilty to tie up peace treaties (you may need to use renegotiate) with deals that can be ended prematurely (other than DoW of course). Military Alliances and lux/resourse imports/exports are the only such deals though, I think. So, for example "Peace + MA vs XY" will result in a state of war between the MA partners if for some reason one side decides to make peace with XY, or if XY is destroyed, before the end of 20 turns. As a hard and fast rule, one side gets the rep-hit, the other side the war happyness.
Have I missed anything?