Preheat oven to 350 degrees (F). Coat a 8 or 9-inch square baking dish with cooking spray.
Place chicken in a medium saucepan and fill with enough cold water to cover the chicken. Set over high heat and bring to a boil. Reduce heat to medium and simmer, covered, until chicken is cooked through, about 10 or 15 minutes. Transfer chicken to a cutting board to cool for a few minutes. Use two forks to shred chicken. You can make the chicken several days ahead and store it in an air-tight container in the fridge.
While the chicken is cooking, heat oil in a medium skillet over medium heat. Cook onion and garlic until softened, about 5 minutes.
Meanwhile, mix together the grated cheddar and Jack cheese in a small bowl.
Transfer onion mixture to a large bowl. Add the beans, tomatoes, green chilies, corn, taco seasoning, salt and 1/3 of the cheese mixture. Add shredded chicken. Stir in sour cream and mix well.
Using the skillet that you cooked the onions in, place over medium-high heat. Cook one tortilla until lightly browned on both sides. Transfer to baking dish. Repeat with next tortilla. While the tortilla is cooking, spread 1/3 of the chicken mixture in the baking dish. Top with the toasted tortilla and another 1/3 of the chicken mixture. Repeat toasting remaining tortilla and top it with the remaining chicken mixture. Sprinkle remaining cheese on top.
Bake for 30 minutes or until the filling is bubbly and the cheese is melted. Let stand for 5 minutes before serving. Serve with sour cream and salsa if desired.