Forums have fallen into disuse, and discord is where the community is at. Please visit us on discord!
You do need to know (and control (gate raiding)) where the AIs are going to attack (open the galaxy map and press W to see hostile wormholes) because that's where you're going to build your defenses. But you don't necessarily need to know when they attack. The purpose of defenses is to prevent and stop attacks if and when they occur. If you don't have defenses.. then obviously there are no defenses to prevent or stop attacks.. so you need to be prepared. You should not have undefended planets adjacent to AI planets. You should have 1-4 "whipping boys" where you take all the waves (whipping boy=a heavily defended planet where the AIs send their waves). I said 1-4 because that's the number that usually works. In most maps you must have more than 1 or 2 whipping boys because that's usually not enough to create a chokepoint. The AI will be able to go past the whipping boys. And 3-4 because that's the maximum number of whipping boys that will be able to stop waves and other attacks (CPAs..). You can only have a certain number of whipping boys because you will run out of Turrets and other defensive stuff so the defenses wont be strong enough to stop the attacks if you have 37 whipping boys. Obviously if a planet doesn't "take waves" it doesn't need as strong defenses. But even if a planet doesn't take waves it can still be hit by a CPA if the CPA fleet is able to past your whipping boys. That's why people build chokepoints. The purpose of whipping boys is to take the attacks and stop them.. and to protect the other planets.. and ultimately your Home Command Station.
Alt + Right-click, auto-load transports.
If it's expendable and strategically irrelevant, don't waste defences on it.