It's called dogpiling. They see that you're at war with someone and decide that now is their best time to strike. Then another one sees that you're at war with two civs and jumps on as well.
One way to avoid that is to bribe them to go to war with each other. You can also give non-aggression treaties a go.
Declaring war pre-emptively can work in your favour if you have moved your armies into position near their cities. Cities are a civ's unit-building capability, so taking as many cities away from them at the start of the war makes an aggressive war go much faster. Don't feel compelled to hold onto an enemy city longer than five turns if it's too far away from your other cities. Raze it or just destroy all the buildings so that if it is recaptured, the enemy has to waste time rebuilding them.
Keep your territory contiguous and increase your borders as much as possible. Enemy units move at the base rate in your territory, so the more distance they have to go to get to one of your cities, the more time you have to respond to an incursion. For that reason, you may want to build a Stables upgrade at any border outposts, so that your units get double movement. Very handy in a forest or swamp.
Use Lower Land to open up new, faster routes for your units to take. Use Raise Land to turn easily-crossed plains into hills, slowing your enemies even outside your influence (but obviously, you can only use it on tiles not inside someone else's influence.
Keep an eye on foreign relations, particularly the AI's current personality traits. These can give you a clue as to which one is going to be a problem. Also, you take a diplomacy hit with any civs of the same allegiance (Empire, Kingdom) when you declare war. So expect them to come after you sooner or later.