It’s amazing how many adults don’t know how to do this, so consider it a “post-kindergarten education” for all of us grown-ups. Someone you know probably needs to see it, so please share!
1) If you had control over the thing that went wrong, then it’s your fault. If someone else also had control over it, then it’s ALSO their fault…but that doesn’t make it “not your fault”, so it’s time to fess up and take responsibility for your part in letting things go wrong. Step one is to admit you screwed up–to yourself, first, and then to whomever you caused trouble for. Don’t try to play down your responsibility (and don’t exaggerate it, either), because that will destroy trust and make the next steps harder. Don’t ask for forgiveness, yet, because at this point, you haven’t done anything to fix the situation.
2) Do everything you can to fix what went wrong. If you can’t fix it, try to compensate the person you wronged in an appropriate way. Money is typically NOT appropriate compensation, unless you deprived someone of physical wealth that they otherwise would have had/acquired. (This includes breaking something that belongs to someone else, or which is yours and would have benefited someone else.)
3) Ask for forgiveness. Keep in mind that unless you literally fixed EVERYTHING that went bad because of your screw-up (which is usually not possible), what you’re actually asking for is MERCY, not justice. Nobody is obligated to give you mercy (by definition!), so be grateful if they do. If they don’t, be understanding and act like a decent person, regardless.
4) Strive not to screw up in this way, again. The more you repeat your mistake, the harder it will be to make amends, in the future. If you ever completely fail to make amends, your relationship with a person will be permanently damaged.
As a final note, this also applies to things that people like to claim “just happened”, like scheduling conflicts, not having money with to pay someone what you promised them, and so on. If you booked the appointment/promised money/spent too much money, you had control over that event. Please be brave and make amends whenever it’s needed! Your social- and family-life will be much better for it.