Yeah, you should be aware of possible attacks by neighbours in general anytime, whether they're gracious or not (you may feel safer when they are busy at war elsewhere or if you pay large gpt).
So you want to build up a decent military and have a larger garrison in border cities. Barracks and walls (for towns that don't grow fast) should increase your protection.
You could also place a number of bombardment units. 3-5 cannons per (border) city help to defend during ai's turn and steal off enemy hitpoints during your turn. Later, you will upgrade them and could use them as well for mainly offensive objectives, due to better range.
Then, you might place a defender on certain tiles like mountains & hills on your territory that are next to your border cities, just to prevent that your enemy occupies them. Let there only be space for your opponent to rest in the open, thus increasing the chances of successful counter-attacks.
In fact, you can defend your border cities so heavily that the ai does not attack there at all, but tries to move offensive units into your main territory, thus losing initiative.
In a current game w/ 3 border cities, England (they had twice as much territory - guess their strenght) moved in about 10 cavs and other stuff each turn (they didn't attack although they could have). At least 30% suffered fly-by shooting every turn and then were red-lined by arties before I finished them with my attackers. By the time, I got exactly 7 leaders from my cavs.
