Prep the oven and pan: Heat the oven to 375°F (190°C).
Lightly oil a 9x13-inch baking dish or similar casserole pan.
Sauté the veggies: Warm the olive oil in a skillet over medium heat. Add the onion and bell pepper and cook 4–5 minutes, until softened. Stir in the garlic and cook 30 seconds more.
Build the filling: Add black beans, corn, green chiles (if using), chili powder, cumin, smoked paprika, oregano, coriander (if using), red pepper flakes (if using), salt, and pepper.
Stir to coat and warm through for 2–3 minutes. Remove from heat, then stir in lime juice and cilantro. Taste and adjust seasoning.
Layer one: Spread 1/3 cup enchilada sauce over the bottom of the baking dish.
Arrange a layer of tortilla halves to cover the base, slightly overlapping.
Add filling and cheese: Spoon 1/3 of the bean mixture over the tortillas, drizzle with about 1/2 cup sauce, and sprinkle with 3/4 cup cheese.
Repeat layers: Add another tortilla layer, another 1/3 of the filling, more sauce, and more cheese. Repeat one more time. Finish with a final tortilla layer, the remaining sauce, and the rest of the cheese.
Bake: Cover the dish loosely with foil and bake for 15 minutes.
Remove the foil and bake another 10–12 minutes, until the cheese is melted and bubbling and the edges are lightly browned.
Rest and garnish: Let the casserole rest for 10 minutes so it sets. Top with extra cilantro, sliced jalapeños, and avocado if you like.
Serve: Scoop into squares and serve with sour cream or Greek yogurt and lime wedges.