PIC32 Peripheral Pin Select for Digital Output
I suspect it's your config bits, the one thing you didn't post.


RA2/3 are the main oscillator pins.
RB4/RA4 are the secondary oscillator pins.
RB5/7/8/9 are JTAG.


All of those pins are affected by the config bits.

Edit:  Now we have your configuration bits available, I can confirm it:


#pragma config POSCMOD = HS             // Primary Oscillator Configuration (HS osc mode)
#pragma config OSCIOFNC = ON            // CLKO Output Signal Active on the OSCO Pin (Enabled)
#pragma config FSOSCEN = ON             // Secondary Oscillator Enable (Enabled)
#pragma config JTAGEN = ON              // JTAG Enable (JTAG Port Enabled)


All those being on, or not set specifically to disabled, will be overriding any and all other functions on those pins.