If you write to an analog pin, set as an output, results will differ from time to time, so Just don't do that

Better practice is to modify your hardware assignment to what your PIC can do, and/or choose another PIC which have more flexibility about analog pin configuration.