I would keep it fairly informal and to make sure to use the word "sorry" without qualification.
1) I was tired last night and i got mad at my friend. On the next day he asked me some thing. What could i say.I want to say sorry.
I'm sorry I got mad last night, I was tired.
Sorry I got mad. I was just tired.
2) How to apologize to my boss when i am late in office?
I'm sorry I'm late. It won't happen again.
Spoke apologies are almost always very informal. Written apologies tend to be much more formal, like:
Please accept my sincere apology for arriving late at the office yesterday.