It's just a way to let you choose a different set of pins for the peripheral functions - for the convenience of your PCB design and/or to avoid conflicts with other peripheral functions.
Look at the chip datasheet for details...
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
I have no idea where you lifted the code from either, people tend to post code here they have problems with, or are a random hodge-podge of cut-n-paste from other similar examples, basically throwing mud at a wall hoping some will stick?
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..