Barring some bizarre cases like Bionx ebikes that need a CAN bus signal between components, most BLDC controllers can control most BLDC motors.
Controller would need a learning function. The order of the 3 phase cables is essentially random. Beyond that, sometimes the eRPM is too high for a certain controller, which is a function of motor gearing and number of magnets. Keep in mind the displays aren't usually compatible with anything else. So the display has to come with the controller.
If your previous bike used hall sensors to determine the motor's internal position and the replacement didn't, you'd also need a controller that lets you change the mode from sensored to sensorless.
Lastly, sometimes there's some cable harness differences. 8 pin vs. 9 pin vs. 10 pin. Brake switches can vary too. Sometimes they bring a signal line down to ground, other times they connect voltage (usually to drive lights).
Throttles are almost universally hall sensors except for a couple potentiometer based ones like on the early Zero bikes. PAS sensors vary quite a bit, though, from various magnets and sensors to torque sensors, and can take different voltages. Some work on 5V, some 10V, etc.. So of the new bike has a torque sensor that needs 10V and your controller only outputs 5V for a cadence sensors hall sensor, you wouldn't be able to use the PAS on the new host bike either.