Is there any way around it though?
There's a way to prevent it, but not to fix it. I'll explain how DLC and the eShop interacts since there's little knowledge about it, keep in mind 3DS themes act like they were DLCs.
Whenever the console needs to retrieve DLCs for a certain title, if your NNID doesn't have one, the console creates a ticket for it, which specifies what DLC you have purchased, so the first time you go into a DLC Shop (or in your case, the theme manager) it creates an empty DLC ticket and gets registered with your NNID. Whenever you use your NNID outside of online gaming (Pokebank, logging into eShop, updating games) the console installs the tickets registered in your NNID, and overrides the "pirated" tickets, if you have one.
So in your situation this is what happens, when you install your custom CIAs, FBI/Devmenu installs the themes in the SD, and a ticket specifying that you own those custom themes, but when you log into your NNID, the original ticket that says you own nothing get installed, and your console stop recognizing you have them (They should still be installed in your console though).
The only way to avoid this is to have installed the pirated ticket before visiting the theme manager (in other words, before letting the 3DS create an empty ticket), the 3DS recognize you have a ticket and doesn't create a new, empty one, the pirated ticket doesn't get registered in your NNID, but it doesn't register a new one either. Thus avoiding the eShop deleting the pirated ticket.
Since you already have the empty ticket registered in your NNID, you will have to either create a new NNID account, or keep the custom theme CIA or ticket in your SD card and reinstall whenever you log into your NNID.
(By the way, this is just information I have recollected while reading the scarce info about DLCs in GBATemp and testing I did on my own).