I like this suggestion. It would make things slightly more historically accurate and make the gameplay more interesting to boot. The only times I've ever wanted to sign DPs are when I have a super-hostile neighbor (cough, cough, Shaka, cough) and want my powerful ally to lend a hand if he attacks.
They also more or less seem to work as a deterrent.
I had a Venice game in which I was DoWed by the neighbor Bismarck a few times. I didn't even have the territory to get a large enough military to deter him on my own. After I signed a DP with Hiawatha, largest military power, Declared friend of Germany and main destination for Bismarck's TR, Germany finally left me alone.
Fairly powerful Rome did DoW Hiawatha a few times, but it played in my favor as Rome generally wanted me out of the way and paid handsomely to get peace just a few turns after the DoW. That let me get promotions for units I kept in a CS near Roman land for that purpose, and then they could return to protect Venice.
As they stand DP are a very, very high risk venture, though - and even if they were changed to target a particular Civ or Civs they would still be high risk (which is fine, the game needs such casus belli... it's boring and unrealistic to be able to plan perfectly diplomacy so no surprise or unforeseen entanglement can happen).
Like this:
In that same game during one of those "white wars" with Rome, Augustus ended up stealing two CS allies from third parties, which meant they declared war on me and of course they were under the protection of a few until then friendly Civs that denounced me and Hiawatha. That sort of entanglements needs to stay. "Defensive Pacts" aren't peaceful, they're promises of aggression to deter aggression or to create a casus belli or disguise the real motives for declaring war. A few great diplomats considered only fools and warmongers with an agenda signed DP, them and the nations desperate from an ally/protector.
What doesn't work right now are situations like the one already described: You have a DP with a declared friend, and another declared friend DoW the first, forcing you to automatically declare war on your second friend... but you're the only one seen as a betrayer.
First of all, you should always be asked if you will honor your word or not first. In the first case, you willingly betray one ally (the attacker) for another (the target you decide to side with), so you should get the betrayer penalty. In the second, you should only get the "broken promise" and
betrayal modifier from the Civ you had a DP with and have let down, but a positive modifier from the attacker. Basically, it should be like the "please denounce X or else..."/pick the friend you want to lose mechanics. Ideally, it would also be some coefficient of diplomatic trust with all other rulers that would affected, but the diplo system is simplistic and doesn't differentiate between you reputation as a trader (trustworthy, fair), diplomat (loyal, honest, honorable etc.) and your peaceful/aggressive bias. Right now a leader offended by your conquests on another continent might refuse to trade when you've had fair deals with him and all your trading partners for centuries, but the same leader won't be offended that those Longswordmen and Knights belonging to his archenemy and stationed all along his borders are there solely thanks to the Horses and Iron you sold to his aggressive neighbor... That's another big overlook that hurts diplomatic immersion... one just has to think of all the grief (and pressure on the Pope to denounce them) the likes of Austria or Hungary gave Venice or Genoa for selling wood and iron to the Mameluke or Ottomans.
With the present system, and since it's automatic, it's the friend who still DoW someone despite knowing you have a DP with him that should get the betrayer penalty, while you only get the one for the DoW. I'm pretty sure the problem is mostly that the diplo calculations have to wait for your DoW. What should be changed is that when someone declares war, the game should look right away for existing deals between the attacker and the civs with a DP to his target, and consider those deals broken immediately (thus the attacker is considered the backstabber of his friend, for disregarding the fact he had a DP with his target). You still would pay the price for the actual DoW, but not for breaking deals. The only other fair alternative would be to divide the betrayal penalties between the two civs involved, since to a point it's mutual.