I do not get attacked nearly as often as I did in BNW, and I don't take any major steps to avoid it. I try to build two archers per city and upgrade them to CBs, then add a couple of horses. This defending force will work for a good long time with half-decent use of terrain. Wonder-spamming will create hostility, as will settling in the face of another civ. And sometimes you just get stuck between Alexander and Shaka, so you know it's going to be a long day. How far apart do you settle your cities? When I used to spread out my cities I had a lot more trouble with early wars. Way easier to defend a nice tight triangle of cities with 3-4 tiles of road between them.