Ships in orbit around a planet will not form fleets if attacked unless you have:
A) An orbital fleet manager, which only effects the planet it is built on, and it will only form a fleet that is equal to your current logistics ability.

A Hyperion Fleet Manager, which also only affects the planet it is built on and it will form a fleet with all the ships orbiting that planet regardless of your logistics.
I'll add an example just to clarify. I have a logistics ability of 15. The Altarians are attacking three worlds that I control
World 1 has no fleet manager and has 5 small defenders (15 logistics points total). The Altarians attack and only one ship will defend per attack- each attack costs 1 movement point. If they have five movement points left they can (and will) destroy all of my ships.
World 2 has an orbital fleet manager with 7 small defenders (21 logistics points total). The Altarians attack and 5 of the defenders will form a fleet. The Altarians destroy the entire fleet and attack again using another of their movement points. The last two defenders will form a fleet and most likely be destroyed by the Altarians.
World 3 has an Hyperion Fleet Manager and has 8 large battleships (48 logistics points total). The Altarians attack and all 8 large battleships will form a fleet which totally destroys the Altarian menace.
The example probably wasn't necessary but I felt like being long winded.