How to prevent bolts from rusting and sticking in the toilet tank?
The best solution is to purchase a new set of bolts that are made of stainless steel or brass. Both will not rust the same way that a iron or steel bolt will. They will cost a little bit more but will pay back in the long term.

My experience has been that the brass bolts after years can sometimes build up their own kind of corrosion that can make it difficult to remove the nuts. This seems to be related to  the water chemistry and to some degree if there is a micro leak by the bolt. Stainless steel bolts are the best in my experience and I have been very happy with the toilet repairs where I have used them.