
Kudaku |

Yes. Both require you to make one or more attacks and both provide stacking bonuses to AC.
You can choose to fight defensively when attacking. If you do so, you take a –4 penalty on all attacks in a round to gain a +2 to AC until the start of your next turn.
You can choose to take a –1 penalty on melee attack rolls and combat maneuver checks to gain a +1 dodge bonus to your Armor Class. When your base attack bonus reaches +4, and every +4 thereafter, the penalty increases by –1 and the dodge bonus increases by +1. You can only choose to use this feat when you declare that you are making an attack or a full-attack action with a melee weapon. The effects of this feat last until your next turn.
However it's worth noting that Combat Expertise only works with melee weapons, whereas Fighting Defensively can be used with ranged weapons as well.

Matthew Downie |

"Fighting Defensively as a Standard Action: You can choose to fight defensively when attacking. If you do so, you take a –4 penalty on all attacks in a round to gain a +2 dodge bonus to AC until the start of your next turn."
"Fighting Defensively as a Full-Round Action: You can choose to fight defensively when taking a full-attack action. If you do so, you take a –4 penalty on all attacks in a round to gain a +2 dodge bonus to AC until the start of your next turn."
According to this you can fight defensively any time you're attacking and it's a standard or full-round action.
Combat maneuvers count as attacks, as do cleaves, spring attacks, spells that make attack rolls, and ranged attacks in general.
Note that with a lot of spells, casting is a standard action, and then you get to make the attack roll as a free action. So if you're playing by literal RAW, you cannot fight defensively in those situations (whereas you could if you held the charge for a round and then made the attack as a standard action).
Aid Another is a bit tricky to judge. "If you’re in position to make a melee attack on an opponent that is engaging a friend in melee combat, you can attempt to aid your friend as a standard action. You make an attack roll against AC 10."
I'd count that as a valid attack for the purposes of fighting defensively, but another GM might not.