Don't connect your device to the internet, and nobody is deleting your books. I sideload all my epubs from various stores and back 'em up. It's mine, not theirs.
That seems like the way to go honestly. Just be careful to back up your books too because just one mistake can be enough to screw you over. I have a friend who ran into that very problem. Enabled wifi just one time without thinking and all his books were deleted. There were a ton of posts about it https://old.reddit.com/r/kindle/comments/18csl9d/all_books_g...
No idea if they ever fixed that or not. My friend had to try to track down which books were even on the device and then re-obtain what he could.
I'd suggest using calibre or similar to make alternate copies of any digital books you buy and storing them as backups in files completely outside any device you use to read them with (especially a DRM'd device). This can get tricky with newer editions of media through devices like Amazon's kindle, but there are usually workarounds. You bought them, they are rightfully yours and fuck any "ownership" model that treats what you bought as something to be taken away from you on a bullshit legal whim.
Also, if some DRM'd digital book you've bought is truly impossible to remove from the device you're using to read it, an alternative is to just pirate a copy from certain obvious sites (cough, libgen, cough) as a backup edition in a format you fully control. Since you did indeed buy the book, also having a pirate copy is at least morally legit as far as compensating the author goes, even if it's legally shaky. Then again, many laws themselves are legally shaky, if not morally too. This applies especially to all the absurd legal contortions and false outrage practiced by proponents of the legal dumpster fire that is DRM.