Just a hunch: some keyboards detect the state of switch pedals connected on startup and auto-configure themselves accordingly: if the switch is closed on startup, they assume it is a “breaker” setup, if it’s open, it is a “closer” setup. With these keyboards, if you accidentally have the pedal pressed while the keyboard is starting up, it will get confused and configure your pedal in the wrong way.
Only solution to this: restart the keyboard making sure that the pedal is not pressed.
Easy to test if your keyboard is doing this - just switch the keyboard on while having the sustain pedal pressed and see what happens…