We figure for Canadian residents there is about a 2% chance per annum that the CSIS and CSE join up to kick in your front door if you so much as touch anything that messes with the software running of a DSi.
More seriously there is probably a lawsuit, historical or current, that slapped a mod chip maker/flash cart seller, possibly even one that was not selling ROMs or some piece of law some paid shills for tech companies shoved in during the 90s when most politicians were born in the 40s to give them all the power (I don't know for Canada but everywhere else in the world tends to get that, and harmonising trade with the US also tends to mean that). Unless you are selling flash carts or ROMs then nobody cares, people walk through airports all the time, I have not heard of anything being stopped in customs in years (and even then would probably only have been a crate of the things for a flash cart seller)... we would not advise it but you could probably go show a policeman and they are more likely to ask how you did that so they can do it for their kids than they are to slap the cuffs on (not to mention it is generally a civil affair anyway).
As far as "prevent me from doing illegal things" then that can mean a few things in flash cart and mod chip world. Traditionally that meant region free and homebrew (the PS1 having a few such chips), no means of running commercial ROMs/isos without further modding. Some may have also extended that to
cheats. If you want to do ROM hacks that necessarily means commercial ROMs need to be run.
For the DS and DSi you are then going to be very limited*, especially if ROM hacks and
cheats are your goal. Instead figure out your own morals and play to them instead -- don't download ROMs you don't own a copy of (indeed some would suggest you dump your own). Flash carts and hacked firmware being your choice for the DSi, personally I like flash carts but there is something to be said for hacked firmwares these days.
*technically there are one or two flash carts with no commercial abilities -- some things from datel (see games and music for one) and ironically enough supercard (who otherwise arguably have the best in class flash cart for the DS) in the iplayer. There are hacks for the former to do things. I also don't know if they will boot on a stock DSi, though I guess you could mod it to boot.
I don't know if there is a nerfed version of the DSi firmware hacks like we see for the 3ds and Switch at times, not to mention most laws tend to be phrased around bypassing protections which those will necessarily have done to boot in the first place and again if we are seeking the ability to do ROM hacks as part of this then that is going to be difficult to do anything there as the poor little cheat engine will not be able to keep up with the mountain of
cheats needed to adapt the average hack to cheat format (if your cheat patch is measured in megabytes then the cheat format will probably be twice that at minimum... I would be mightily impressed with cheat engines that make it past about 100 lines of cheats per game, never mind the complicated extra setups that would likely be needed for that one), and nobody has yet done any file replacement stuff for the DSi that I have seen (some for the 3ds and switch).