Error reading data through UART using peripheral library in PIC32?
Assuming you only want it to do one or the other, you need to modify your code as follows:

char RX_data = ReadUART1();
if(RX_data == '1')
{
    LATDbits.LATD5 = 1;
    putsUART1("LED ON");
}
else if(RX_data == 'q')
{
    LATDbits.LATD5 = 0;
    putsUART1("LED OFF");
}


If you logically step through your original code, you will see that when you enter 'q', it gets read and compared to '1', which it doesn't match, but then you perform another read, so you lose the 'q' that you'd already read.