TLDR
- Retreats are possible for the attacker.
- Retreats are not possible for the defender, ever.
- Land and Sea units retreat as expected. They all withdraw to a friendly adjacent space. They only possible unexpected point is that even if they came from different spaces, they all retreat to the same space that at one of the "units" attacked from initially.
- Air units retreat after the noncombat movement phase as if they had a successful attack. I assume this gives your opponent a chance to destroy it prior to a successful retreat.
- The only attacking units that can not retreat are the units that landed during an amphibious assault.
So I downloaded a copy of the rules from the axis and allies website. First thing I came across regarding your question is this on page 14
...If no seaborne land units survived the sea combat, or if the attacking sea units retreated from the sea combat,...
So yes, retreats are possible. Then I came across the actual retreat section:
Retreats: Keep the attacking overland and seaborne land units separated on the battle strip. Attacking seaborne units cannot
retreat. Attacking overland units and aircraft can retreat as normal at the end of any round of combat (see “Step 6: Press Attack
or Retreat” on page 17). All attacking overland units must retreat together as a group, at the same time and to the same place.
They can retreat only to where at least one of those units moved from. Attacking air units, whether involved in the sea combat or the attack on the territory, can retreat as normal. Air units and
overland units (if any) must retreat at the same time. However, the air units do not land until the Noncombat Move phase.
I do not know for sure but I assume that the reason the seaborne attack could not retreat is because in real life the transport would get off the beach for the next transport to unload and/or to not get destroyed by enemy fire for no reason.
The section on page 17 regarding retreating says as follows:
Condition B—Attacker Retreats
The attacker (never the defender) can retreat during this step.
Land and Sea Units: Move all attacking land and sea units in that combat that are along the battle strip to a single adjacent
friendly space from which at least one of the attacking land or sea units moved. In the case of sea units, that space must have
been friendly at the start of the turn. All such units must retreat together to the same space, regardless of where they came
from.
Air Units: Retreating air units remain in the contested space temporarily. They complete their retreat movement during the
Noncombat Move phase using the same rules as air units involved in a successful battle.