You're too busy building just your economy.
There should be a statistic-screen from your current game in the upper right corner where you can see what you are best at and what you are worst at. Being the 16th in military is a bad sign in a 16 player game. I try to be at the top 4 usually so the AI thinks twice before attacking.
also if you allways agree to every "open borders"-treaty the AI will just scout your area and army and decide if it has bigger force than you.
Best allies are the ones who aren't next to your borders, because they will be less tempted to attack you because of the distance.











