Yeah, that was the problem. All you have to do to trigger the MPP is give the appearance of an attack - put one foot in their territory, or even bombard their territory. If they took your town, then you don't get a chance to move - if you had any units outside, but near the town, they trigger the MPP. Bad luck...
Apologies for the 20 year necro, but this quote above turns out to be the best definition of what triggers an MPP. I had my MPP buddies declare immediate war on a foe that had not attacked me in the turn after I signed the MPPs. So simply being in hostile territory is sufficient to trigger it and as noted in the post above, this can include coastal territory.
Other interesting developments on the MPP diplomacy front have happened in my most recent game.
I as Russia, am attacked by China. I make desperate MPPs with Arabia and Korea, on the same turn. 17 turns in to the MPP and Arabia still has their MPP with me, but Korea’s has disappeared with no dialogue to explain it expiring (presumably somehow as a result of making peace with China. But this does not make sense and is not consistent with other examples of MPPs being maintained after peace is made with the mutual enemy).
Additionally, all sorts of MPPs kick off and I have a world war. France declare war on me and I wait until I can drop my MPP with Arabia before making peace with France (to avoid re-entering war with them unintentionally). Bizarrely, in the save game file, if I speak to France first (with MPP active with their foe Arabia) then France will accept peace and even pay me for the privilege. However, if I speak to their enemy Arabia first and cancel the MPP then France will not accept peace (even though on paper I am much more distant from their foes Arabia). I guess the French AI must have been combining the strength of myself and Arabia in wanting to pay me for peace but when the MPP is cancelled just calculated my strength in isolation and decided they could bully me. So in summary, I think possibly getting MPPs in wartime could be a tactic to strengthen your hand diplomatically when looking for a peace deal. Albeit, it greatly risks you ruining your reputation by re-declaring war during the 20 turn initial peace if you don't do it properly.
Anyway, I thought I'd post this as these are intricacies that were surprising to me. I don’t have a problem with any of the above as it feeds into a sense of unpredictability and diplomatic inconsistency which I quite like. But heck, it is hard to keep any sort of rules in your head.