Jim Sterling nailed it when he said sonic got progressively worse because of sega not trying to stick with one style or idea and flesh it out. Instead Sega kept on trying to "reinvent" the series, hoping to find a new formula that will instantly make the sonic series good again.
The difference between Mario and Sonic is that Mario is a fully fleshed out character who everyone is familiar with. There's a certain kind of formula with any Mario game, and it's been worked on so meticulously that there's a quality standard you can expect with Mario games. Because Nintendo has stuck with the game formula, it's allowed them to be able to adapt the series and keep it somewhat relevant. The same thing can't be said for Sonic games.