I suggest that you do not try to unlock and lock the PPS registers until you have everything else working correctly.
The unprogrammed default is to have the IOL1WAY bit set in the config registers which means that you can only unlock the registers once - once you lock them then you cannot unlock them again (until a power cycle) even if you do use the correct unlock sequence.
However the power-on default for the IOLOCK bit is to have the PPS registers unlocked. Therefore you can set them however you need to without the need to do the unlock sequence - just DON'T lock them again afterwards.
In your first code snippet, you are trying to use C to perform the unlock and lock sequences. This may or may not work depending on how the compiler generates the instructions. The unlock sequence must be performed as sequential instructions as given with no intervening code. This is why the macros (that you use in the 2nd snippet) are provided by the compiler.
Susan