Exactly. Rex's defense got him fired. The Tyrod led offense with the Bills 2013 or 2014 (pre-Rex) defense and Buffalo makes the playoffs. Especially with that 2014 defense.
Tyrod is far from the reason Rex got fired. It was his defense, and just his overall incompetence as a head coach - not even getting the proper number of players on the field, or play calls in on time. Not being able to properly teach his defensive scheme. The embarrassing amount of penalties and the list goes on... it was just his overall circus act that got him fired.
If Rex had shown to be a competent coach that had things moving in the right direction he'd likely still be here. But it was clear to most everyone that was not the case, hence why he wasn't given more time. I don't think Pegula liked being a constant national media punchline under Rex, either...