First, I suggest making just one loop and check all buttons inside of it.
.
You need to link players with their gamepads. You can add an instance variable GamepadNo to the player sprite. When a button is pressed on gamepad #1, pick a player with GamepadNo=1 and control it.
.
Or you can do this with an array, for example X-index of the array is the player number, and the value is gamepad number. So for 4 players your array may look like this:
x=0: 3
x=1: 0
x=2: 2
x=3: 1
You fill this array at the start of the game, when you ask each player to press a button on their gamepads. Then in the game when a button is pressed on gamepad with index 1, you know that it belongs to player #3.