From Newbie FAQ:
13.1 Mega Evil Empire (MEE)
13.1.1 Settings.txt governs if & how MEE is used. Basically, if used, this system tries to limit an empire from running away quickly and winning the game. If a player is declared MEE, all AI’s will declare war on that player. A human or an AI can be the MEE. It does this by comparing the #1 player’s score with an absolute value and to the #2 player’s score. With default values, a human player becomes MEE when his score is 500k and is 170% of the next highest player. It is a little more forgiving on AI’s since they won’t be MEE until their score is 250% of the #2 player. New players are sometimes unaware of this and can’t understand why a game is going great and then suddenly the whole galaxy appears to turn on him. This is why.
Briefly, the AI sucks in SE4. As you have noticed it can declare a war without a reason.
The key to win is expansion. Expand as much as possible and research mines for early defence. Then research components required for your basic ship, light cruiser. A light cruiser equipped with four large mounted phased polaron beams, one or two point defence cannons, ECM, combat sensors and some armor are effective. Also
remember to train your ships! Do not attack without 20% ship and 20% fleet experience and enough mine sweepers.