Preheat the oven to 375°F. Spray a 9×13-inch casserole dish with cooking spray.
Set a large skillet over medium-high heat and add the olive oil. Once hot, add the chopped onion and cook for about 3 minutes, stirring frequently, until softened. Stir in the refried beans and cook for another 3 minutes, until heated through. Remove from heat and stir in 2 cups of the shredded cheese.
Lay a tortilla flat and spoon about ⅛ of the bean mixture down the center. Roll tightly and place seam-side down in the prepared baking dish. Repeat with the remaining tortillas and filling.
Pour the enchilada sauce evenly over the tortillas, then top with the remaining 2 cups of shredded cheese. Cover the dish with aluminum foil and bake for 30 minutes. Remove the foil and bake uncovered for another 10 minutes, until the cheese is melted and the sauce is bubbling.
Let the enchiladas rest for 10 minutes, then serve hot.