So.. when bad things happen, there are usually two types of meetings. Which one (or both) depends on the situation, the culture and the personalities:
1 - The True Chew Out Meeting
If this is really about "you guys really messed up, if you do it again this will be the repercussions" - then no it is absolutely not OK for you to be invited. This is a reprimand and no one wants and audience when they are reprimanded. Be respectful of your boss and your colleagues and if you are omitted, be happy and don't attend.
2 - The Lessons Learned Meeting
I'm sure many cynical people will call a lessons learned meeting a chew out meeting. But I don't.
A good lessons learned is brainstorming and analyzing - what went wrong? how can we fix it? what are our challenges and barriers and opportunities for trying something better in the future? It's inclusive, and forward looking. There will be enough discussion about the problems to clarify the impact, but it intentionally avoids blame.
If you were impacted, or you know you would be a good part of the solution - you may ask "is this a lessons learned meeting? would my attendance be useful?" if you know this sort of meeting is happening.
Be prepared for "no" - there's all sorts of reasons, but the boss gets to decide in a touchy situation, who's a good part of the discussion and who should be omitted. The pantheon of reasons are too diverse to mention -- don't take it personally.
If the instinct to run towards the fire hits in reality - take a second and do some soul searching. If you honestly think that you can be a productive part of a lessons learned and the outcome would meaningfully affect your work, then proceed.
But realize - most people do love some drama, and it's much better to be part of drama where you are not to blame. The initial gut reaction of "I want to be a part of that" may be a desire to learn coupled with a desire to behold the play out of interpersonal relationships. It's easy to be convinced that passive learning will be useful here - but if it's so outside of your range of meaningful influence that you don't share in the ownership of the problem or the solution - curb the need and ask the participants later if there's anything you should know.