How do I replace this bathroom fan with a different plug?
The conventional way this is dealt with is to replace the whole fan unit housing with all innards with a new one. With luck you can find a replacement with the same or similar housing size.
If, as your question suggests, you intend to just try swapping out the motor and fan blade subassembly then you need to carefully check that the new unit is in any way compatible with your old fan housing. A number of things need to be looked at in addition to the AC power connection:

Is the fan blade assembly the same diameter, depth and blade pitch?
Does the motor mount in an identical manner?
Does the motor rotate in the same direction?

There are very similar style motors used in these types of fans but there are probably as many variations as there are manufacturers and model types that they build.
If you do get lucky and believe you can acquire a fully compatible motor assembly then  you will have to get creative if you hope to use it. That connector type used on the old motor is a very common part that you can purchase from places like Mouser or Digikey. Then with a new connector you install it onto the cord of the new motor. Be aware however that doing this may invalidate the UL safety rating of the fan if you start cutting up approved parts.