Despite Ace Attorney's writing being very dependent on the game and the individual case, Shu Takumi truly understood how to design a framework for a "mystery", and said framework has been what's carried this series for the last decade, even when it's been directed by other directors. By the time you enter a case, it is rare that you ever have the full picture of what's going on. Trials are split into multiple parts, new characters are introduced, new evidence is found throughout the duration of the game. It makes for a perfect formula that constantly keeps the player on edge. When the good attorney is backed into a corner in an Ace Attorney, it actually feels like you're backed into a corner, because most of the time you're hanging onto a wing and a prayer - hoping that a single contradiction will manage to become something bigger. Something like that could only be accomplished in the format Ace Attorney offers; where you are constantly discovering new information and evidence due to the game's willingness to pace itself. The payoff to finishing a case is immeasurable when the writing is firing on all cylinders, and even though unfortunately culprits are usually obvious under the formula, it's a fair tradeoff for better writing and better twists. It's normal to go into the last day of a case already knowing who's responsible and instead trying to figure out how to nail them, with the trials not sparing on their own sets of twists and turns that reframe your entire understanding of the case itself and your opinion on the characters. Thanks to Ace Attorney's formula, part of the intrigue at times is figuring out how to expose your opponent in a system stacked against you in a way that upholds a willing enough suspension of disbelief. Several cases like these include Turnabout Goodbyes, Farewell My Turnabout, Bridge to the Turnabout, Turnabout Reclaimed, The Rite of Turnabout and Turnabout Revolution; all incredible cases in their own right which don't hold back on the moment-to-moment character beats.
Danganronpa meanwhile, isn't as great when it comes to setting up a good mystery, and I think much of this comes down to how gameplay is excessively frontloaded by design. Because the game wants to get you to know multiple characters, it makes it harder to compartmentalize the trial segments with free time segments, and you're only ever given one opportunity to gather evidence, followed by one very prolonged trial that needs to get everything out of the way in one stretch. A common critique of Ace Attorney is that it's normal for you to have figured out a mystery already, despite not being able to lay it out until the game decides it's time for the protagonist to figure it all out - but this is especially a problem in Danganronpa when all the bits and pieces are instantly available before you set foot in the courtroom. Because of this, it's only somewhat infrequently that the player really feels backed into a corner in these games despite how much the stakes are "higher" than an Ace Attorney game, and it's only sometimes when info discovered inside the courtroom turns out to become a real "twist" that steers the course of the trial in a new direction.
When these games have to fall back on their plot, which is the backbone of the major twists and events they set up, is where these games usually fall short. Danganronpa overall is way more plot-driven than Ace Attorney, with the individual cases being "hurdles" in the road to get there, so much of the games' overall impression will be contingent on how well that plot sticks the landing for people. Having said that, I think Danganronpa 2 is a game that can stand alongside some of the best "Whodunnit" games, including the Ace Attorney's finest, and is also the only game where the outcome of the grand mystery doesn't preclude the importance of how characters got us to that point. It actually does a great job in setting up a mystery that allows the characters to thrive. That's a thing that Danganronpa carries as an advantage; a lot of deaths and character beats carry a greater heft when you know anyone can die at any moment's notice, which is gonna hurt if you allow yourself to get attached to anyone. In Ace Attorney you're usually not allowed as much of an opportunity to care about its victims that much. Then again, death as drama isn't always a guarantee that the stakes will remain as high as one would like to think, and it all comes down to the writing of these games which overall Danganronpa needs to consistently hit home runs with due to retaining a limited cast per.