During combat, players can only cast spells and activate abilities at certain times.
To paraphrase and shorten the rules it basically goes like this:
- Beginning of Combat step
- Any beginning of combat triggers trigger.
- Active player gets Priority and can cast spells etc.
- Priority passes to next player, when all pass we move to next step.
- Declare Attackers step
- Active player declares which creature(s) he is attacking with and who he is attacking.
- Valid attacking creatures are tapped and considered "attacking" and any appropriate triggers trigger.
- Active player gets Priority and can cast spells etc. Priority passes to next player, when all pass we move to next step.
- Declare Blockers step
- Defending player(s) declares which attacking creature(s) he is blocking and which of his own creatures he is using.
- Valid defending creatures are considered blockers and the creatures they are blocking are considered blocked and any appropriate triggers trigger.
- Active player gets Priority and can cast spells etc. Priority passes to next player, when all pass we move to next step.
- Combat Damage step
- Active player declares how his attacking creatures apply their damage (assuming no other rules give that choice to anyone else)
- Damage is dealt, creatures die, Triggers trigger
- Active player gets Priority and can cast spells etc.
- End of Combat step
- Triggers trigger
- Active player gets Priority and can cast spells etc.
Obviously, only when players get priority can they cast spells and activate abilities. One of the big changes that happened a while back in Magic Rules was basically around the timing of when stuff could be done in combat. For example, if you want to regenerate a creature now in combat, you need to declare that you are using the regeneration at the end of the Declare Blocker's step. You can't do it in response to how the damage is assigned in the Combat Damage Step.
Similarly, if you want to do anything that will affect whether your attacking creature can or can't be blocked, you have to make that decision in the Declare Attacker's step - i.e. BEFORE the defender declares his blockers. You can't do it in response.