Using a partial binary number like TRISIO=%01011 does not set GPIO.5 up as
an input.

The remaining upper 3-bits are by default 0's, so you're forcing GPIO.5 to be
an output.

Output port latches power-up with an undetermined value, so you don't really
know if you're shorting the pin with a high or low, but you definitely are.

Even pins configured as outputs can be read, so while you're grounding or
taking the pin to Vcc, it's still going to read the pin & react accordingly.

Make the pin an input. Should clear up whatever problems you're having.