Nintendo 3DS generates a random key to encrypt and protect the data on your SD card, including the games and saves. After you format the SD card, the old key is gone and a new key is generated. You can't decrypt the SD card without the key. As a result, you are unable to access the pre-installed games as well as saves.
Fortunately, if you've tied the games with your Nintendo Network ID, you just need to go to the e-shop and re-download the games without purchasing them again. If not, you can call the Nintendo support center to restore your games on the SD card with the serial number of your system provided. In these two ways, you can have the games back.
However, it's impossible to restore your game saves as what's explained above. No key, no decryption. Next time you should make full preparations if you want to format the SD card without losing data. If you have a Windows or Mac device, you can try recovering data from formatted SD card with professional data recovery software such as iBoysoft Data Recovery.