This is usually a twofold question when it is asked so I will assume it is so here.
GBA on the DS- as far as running GBA code as a GBA goes nothing will allow you to change the buttons the X and Y buttons other than a hardmod which you will have to design and do yourself (there was a chip to add rapid fire on GBA to the DS X and Y buttons once but good luck finding it).
If you are running an emulator like those seen on the iplayer, ismart MM/ISMM and DSTwo you can remap buttons as you see fit, the emulator (they more or less share one) is good and can get a lot done but not as a good as the real thing.
Anywhere that runs GBA roms on hardware- you can hack the rom to do it and indeed several people have hacked DS roms which work in more or less the same way to change the controls. You can often get it down to slightly advanced cheat level as well rather than anything fun with assembly and hex editing roms. http://nocash.emubase.de/gbatek.htm#gbakeypadinput and http://crackerscrap.com/docs/sfchacktut.html as well as the zelda and guitar hero control hacks should tell you most of what you want to know here (general idea is you figure out if and where it stores the data read from the register/memory section noted and change the thing from flipping a bit for A to making it flip the bit for B instead unless you want to get really crazy and hack the rom to read different things (you do not)).
You can also rewire buttons on a GBA or DS as well I guess.
Nothing will allow you to change the X and Y buttons other than a hardmod, which you will have to design, and do yourself. There was once a chip to add rapid fire for GBA games, to the DS's X and Y buttons, but good luck finding it.
Like Fast says, any emulator allows you to map buttons as you see fit, and cheats are the way to go if you're using a flashcart to run DS ROMs. As for actual carts, you'd have to mess with the hardware of your DS, which I don't recommend even if you know what you're doing.
Any flashcart with a built-in cheat function (that is, every one I know of) can be used to remap DS ROM controls. You just have to ask on the cheat forums, or learn how to design cheat codes yourself. I know of a couple of control remaps (most of them allow the use of the face buttons in touchscreen-only games); the original Scribblenauts has one, and so does Phantom Hourglass.
As for GBA games, you need a flashcart capable of running a GBA emulator, and from what I've heard most people seem to like the Supercard DSTwo the best. At least, it's the one I hear mentioned the most.
Well that is a shock- divineo actually good for something.
The logic behind the DS control tweaking cheats is not any different to the GBA control mapping cheats (indeed I probably should have pointed out something like the tilt games (yoshi tilt and tumble and warioware twisted) that did more or less the same thing). It might be harder to do on the GBA if you are trying to patch the binary in ram (it more or less runs from the ROM section aka game genie territory rather than the ram like the DS which is fair game for cheats) to do the swap for you (again I would not even consider trying to get the game to change how it reads and interprets controls to read a instead of b unless they have a remapping option in there already you want to try adapting a bit) but that is the hard way when you can probably just get the cheat engine to do a bit of boolean logic on the section it is debounced to (it is pretty similar to http://gbatemp.net/topic/322718-screen-swap-see-touch-screen-on-top-screen-vise-versa/page__view__findpost__p__4137208 if I think about it).
As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The...
While rumors had been floating about rampantly as to the future plans of Nintendo, the President of the company, Shuntaro Furukawa, made a brief statement confirming...
Nintendo has officially announced that a successor to the beloved Switch console is on the horizon. As we eagerly anticipate what innovations this new device will...
Retro handheld manufacturer Anbernic has revealed its first clamshell device: the Anbernic RG35XXSP. As the suffix indicates, this handheld's design is inspired by...
After several months of work, the Harbour Masters 64 team have released their first public build of 2Ship2Harkinian, a feature-rich Majora's Mask PC port. This comes...
With the vast success of Super Mario Maker and its Switch sequel Super Mario Maker 2, Nintendo fans have long been calling for "Maker" titles for other iconic genres...
After rumour got out about an upcoming NES Edition release for the famed Nintendo World Championships, Nintendo has officially unveiled the new game, titled "Nintendo...
The number of layoffs and cuts in the videogame industry sadly continue to grow, with the latest huge layoffs coming from Microsoft, due to what MIcrosoft calls a...
Ubisoft has today officially revealed the next installment in the Assassin's Creed franchise: Assassin's Creed Shadows. This entry is set in late Sengoku-era Japan...
Another day, another great emulator that makes its way into the Apple Store for more users to enjoy. With Apple opening its store up to videogame emulators earlier...
Nintendo has officially announced that a successor to the beloved Switch console is on the horizon. As we eagerly anticipate what innovations this new device will...
While rumors had been floating about rampantly as to the future plans of Nintendo, the President of the company, Shuntaro Furukawa, made a brief statement confirming...
Palmer Luckey is known for his pursuits into the world of virtual reality, having founded Oculus and designed the Rift VR headset. Prior to the $2 billion dollar...
As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The...
After several months of work, the Harbour Masters 64 team have released their first public build of 2Ship2Harkinian, a feature-rich Majora's Mask PC port. This comes...
Ubisoft has today officially revealed the next installment in the Assassin's Creed franchise: Assassin's Creed Shadows. This entry is set in late Sengoku-era Japan...
After a little more than three years of exclusivity with the Epic Games Store, Square Enix has decided to bring their beloved Kingdom Hearts franchise to Steam. The...
After rumour got out about an upcoming NES Edition release for the famed Nintendo World Championships, Nintendo has officially unveiled the new game, titled "Nintendo...
Sony is once more attempting to reintroduce players to their older library of games by re-releasing classic PlayStation 2 titles onto the PlayStation Store. During...
Retro handheld manufacturer Anbernic has revealed its first clamshell device: the Anbernic RG35XXSP. As the suffix indicates, this handheld's design is inspired by...
I've put down the money on the Odin 2 Mini since I just love that Vita form factor. Loved the power of the Odin 2 but the size always put me off, this one seems exactly what I've been wanting.