A minimum of three parts make up a good apology: a description of the act warranting an apology, an expression of remorse for your contribution to that act, and a expression of intent not to repeat the transgression. A fourth part is optional but encouraged, and that is an attempt to atone for the transgressive act. Ideally, the apology should be spontaneous instead of in response to external pressure, but that is not strictly necessary; its sincerity matters most, and oftentimes one ends up truly repenting in response to others' reactions to the act.
Example: "I'm sorry I threw your homework out last night. I was careless and thought that it was part of a pile of scraps for the recycling bin. I promise to be more careful when cleaning house next time so I don't accidentally throw out any of your stuff. Would you like me to help you rewrite it?"
Describing the transgressive act shows that you understand why you have wronged someone, or why that person feels wronged; just remember that tactfulness is key, as does no good to go into gory detail, and may do harm. The expression of remorse is possibly the entire reason for the apology, and without this you may as well not be making the apology at all. Similarly, an apology that does not indicate that you will try to avoid future transgressions leaves the recipient wondering whether they can trust you to behave yourself, or whether you are simply mouthing platitudes -- or concealing ulterior motives.
A bad apology: "I'm sorry your homework got trashed last night, but if you kept the table looking like less of a sty, it wouldn't have ended up in the garbage." Translation: "It's your own damn fault, so stop whining about it."
This apology avoids personal responsibility and places blame on the victim. Also, instead of offering assurances that the victim need not expect being wronged again, the implication is that the victim should expect to be wronged repeatedly unless they do what the speaker wants. In short, this apology is an attempt to manipulate the victim's behaviour and alleviate the speaker's sense of guilt, and deflect attention from the speaker's actions to the victim's. The key part of this apology is the fact that the speaker does not actually admit to having committed any wrong.
Another bad apology: "I'm sorry that you felt bad when I called you a snotty, self-centred, whorish bitch a few months ago. I haven't been able to concentrate since you cut me off from your life. I really feel bad about, you know, everything.
...do you think I can borrow $100 to get my hair highlighted?"
The above apology is completely self-centred and self-serving, and lacks any expression of empathy with the victim of the wrong. The reasons for its unsuitability should be self-evident.
Under no circumstances should you imply that victim's feelings are solely, or even mostly, because of their perceptions of your action. This destroys the purpose of an apology as your admission of wrong and makes you seem particularly insincere.
Also, be aware that your apology may not be accepted in the best manner possible. In some cases, you may even be rebuked for daring to show your face again, if your transgression is a particularly heinous one. Sometimes the best course of action is to simply leave the person you have wronged alone. Remember that the person who have wronged is under no obligation to forgive you, and if you have that expectation, it is best you do not approach them.
Finally, if you do not regret your actions, do not say that you do, even if pressured by others. The victim of your actions will only be hurt further by your insincerity, and will only think worse of you. You may be able to make yourself look better in the eyes of third parties who want to avoid conflict, but if that is what you are concerned about most, this is not the article for you.