Beyond stationing fleets, you can build defensive structures to protect your systems from attack.
Fortifications
The Fortify command strengthens a system's defenses. Fortified systems generate defense platforms that fight alongside your fleets during battles.
Defense Buildings
Certain colony buildings improve system defense. Planetary shields, missile batteries, and orbital platforms all contribute to making your systems harder to invade.