As I understand the rule, when you move *from* a threatened square, you provoke.
When you attempt to cast a spell, read a scroll or fire a missile weapon while in a threatened square, you provoke. Rising from a prone position provokes. Attempting certain maneuvers, such as Bull Rush, Unarmed Strike, Grapple, Sunder, Disarm or Trip provokes unless you have the appropriate feat that says otherwise.
No, you can't take a 5 ft step and then take a move action. You get either a ft step, or a move, but not both in the same round. If you could, you could 5 ft step to disengage, then do a Partial Charge and attack someone else in the same round.
If you Withdraw, you get the first 5 feet of movement free from AoO. After that you're on your own, and can provoke (which is one of the things that makes Reach so powerful). The idea seems to be that you're being defensive as you pull back, keeping your guard up. You can take no other action in a round where you Withdraw.
The 5 foot step is likewise presumed to be done in a way that keeps your guard up, and so it doesn't provoke.
Casting Defensively prevents spell casting from provoking, but requires a Concentration check, to reflect the split attention required to cast spells while watching and defending against a melee opponent.
The Attack of Opportunity takes place when they *begin* the action that provokes it, not during or at the end. And that's important.
Consider the Improved Trip maneuver. I Trip someone and get a free shot at them while they're down, just as the book says. They try to get up, which provokes. My Attack of Opportunity takes place while they're still on the ground, before they rise, so I can't Trip them again (and get another cheap shot to follow), keeping them down. If I could, they'd never get up again, and that maneuver (which many consider questionable already) would be well and truly broken.
Or, in the simple case, when someone decides to dance back 30 feet and shoot me with their bow. The move provokes, and the attack *can't* happen after they're 30 feet away. It has to happen while they're still in that starting square.
Unlike 1st and 2nd Edition, injuring a spell caster *before* they cast their spell doesn't fumble their spell or force a Concentration check. Only damage done while they are casting can do that. That means either an Attack of Opportunity, or someone who had Readied an Action so they could interrupt. The whole "before" and "after" concepts kind of became meaningless with cyclic Initiative.