So my question is, what are these parts purpose?
It looks pretty much like a reverse voltage protection circuit. In other words, if the incoming supply to VIN were incorrectly connected regards polarity, the MOSFET inside your red/orange box would turn off and prevent your circuit smokingbattery getting reverse polarized.
Here's a link to a site that explains how it works. It uses a slightly different gate bias circuit but, in essence, it does the same thing.
Here's a link to a Q and A on this site that might help.
However, I notice that VIN also connects to pin 4 of the TP4056 so, maybe your circuit designer started off with good intentions but missed a trick later on.