When the motor is engaged, the KT controller can figure the speed since it's spinning the motor. If it's a geared motor, the KT controller has no motor signal when coasting, so it switches to the speed sensor.
You set P2 to a nonzero value to tell the LCD that you have a speed sensor. The value of P2 is how many times the sensor flashes per RPM, This is often 1, but some bafang motors use 6. Your P2 probably needs to be 6, but it were working you would get a speed, just 6X higher, so there must be a connection problem.
Is this a plug-n-play KT controller with the same big motor connector on both the new controller and the motor? That should pick up the speed sensor connection automatically, if your motor has one.
If you had to do re-wiring of the above motor cable, the speed sensor wire in a bafang cable is the white wire, It shares the power on the red/black wires that are used by the Hall sensors. If by chance, the speed sensor on your motor got burnt out (it has happened to me), you can install an external one on the wheel.