To be fair, Super Mario 64 on DS isn’t the best example given it wasn’t really the flagship DS launch game from Nintendo - that would be WarioWare Touched. And it certainly didn’t represent the majority of Nintendo’s output on that system after launch, where it was evident the platform in general had been rushed out due to the impending launch of the PSP.
As DaveLong mentioned, Nintendo tends to design games that are a good fit for portability, so a lot of console titles and series did tend to be a good fit for handhelds - see Fire Emblem and Advance Wars which both began on consoles.
If you had to conflate another factor which might explain why some console games fit handhelds, I’d say the era they were made in tends to lead to a more immediate and directly interactive game. For instance, I’ve been playing Twinbee Portable and that’s a great fit for the PSP despite its console and arcade origins. As is the likes of 3D OutRun on the 3DS, and Final Fantasy V Advance on the GBA. It wasn’t really until generation 4 when Japanese RPGs tended to gain bloat, after all, when 80 hours of play time became a selling point on the back of the box. Mario Kart is another example of a game made in an era where arcade sensibilities - heavy interaction within a small amount of time - ruled.
As console development began to play to the bigger and better mindset, it was no surprise that handhelds like the GBA continued on the same design sensibilities as titles on the SNES and MegaDrive in its original games. The DS was a different story due to its unique hardware and approach opening the door to wholly new types of games made solely for a portable system. But that didn’t stop it from getting 16- and 32-bit era ports, of course. Stuff like Chrono Trigger works better for travelling or casual sessions than the likes of Resident Evil: Deadly Silence.
The PSP, with its UMD drive and capability to play the kind of games being made on consoles in generation 5, inherited some of the bloat that came with the console space at the time with its software library.