From a historical perspective, it's Super Mario Bros, hands down. It's the game that essentially saved the console market in North America and defined the platformer genre for the next decade. It's possibly the most iconic game in history. Sonic is iconic in his own right, but Mario is *the* face of video gaming.
From a gameplay perspective, it's a bit closer, but with the edge still going to Mario. SMB was a master class in level design, including how to use the levels themselves to teach players how to play. There's a reason why World 1-1 is the most heavily studied level in gaming history. Mario also handles very well and intuitively. The roster of enemies also provided good variety... except in the bosses department, with the fourth level in each world having the same Bowser fight over and over, with only a couple of tweaks here and there such as adding blocks to make maneuvering tougher or having Bowser toss hammers. Also, if you're used to more recent 2D Mario games, the original actually has quite the difficulty curve, further added to by it being incredibly stingy with the 1-ups and having some opaque puzzle elements in a couple of levels (made more comprehensible through audio cues in the All-Stars remake).
Sonic did have some better QoL aspects thanks to being a later game. For example, it had an actual continue screen as opposed to having to know a secret button combo on the menu screen to continue like in SMB (though you did have to earn continues in Sonic). It also had more variety in its approach to level design, with some levels focusing more on building and maintaining momentum and others on more traditional platforming, and you even had Spring Yard Zone's focus on just getting bounced around everywhere. The various boss battles were also pretty solid. However, the focus on speed runs headlong, literally, into issues with enemy placement where players can just run right into a foe before they realize it. There's also the Labyrinth Zone, which started the trend of tedious water levels in Sonic.
From a personal perspective, SMB was a formative game for me. It was the first NES game I saw, and when I saw it I was blown away. Same for the other games I remember seeing or playing. I had to have an NES, and on Christmas of '88 I finally got one. The NES and SNES are probably tied as my favorite consoles ever. Super Mario Bros made me the gamer I am today.
Sonic, meanwhile, was more of a pleasant surprise. Great game, but wasn't as impactful. I didn't know much about the Sega Genesis, and only knew of it because it was in the old Sears Christmas catalogs. But I got a Genesis for Christmas 1991. I was hoping for an SNES, but I imagine my mom saw the Genesis was cheaper and thought to herself "Eh, it's a video game. He'll like it." And I did. The Genesis was a great system, and the Sonic games were my favorite titles on it. I always felt that Sonic 2 was the best in the series, as it played better than the original and felt more polished, but the original still holds a lot of good memories for me.