I'm sure that someone more knowledgeable will be along with a better explanation, but in my experience:
xinput gamepads (xbox 360 controllers)have some sort of on board device ID and windows assigns the player # based on that.
(so they can't be re-ordered)
direct input gamepads are assigned an order based on when they are plugged in.
This made an extra wrinkle in using hacked xbox360 fightpads on my cab sincexbox360 controllers are both direct input gamepads and xinput gamepads based on what the game supports. I had to figure out which pad would be seen as xinput controller #1, then unplug them and replug them in the correct order so it would also show up as controller #1 for games that only accept direct input.