It is possible for the magnets in a motor to be installed backwards, but this is very unlikely to happen during the manufacturing process. This is because the magnets are typically glued or otherwise attached to the motor housing in a specific orientation. If the magnets were installed backwards, the motor would not be able to generate torque and would not be able to operate.
In addition, the motor would not have been able to pass quality control if it had been assembled incorrectly. Quality control checks are conducted on all motors to ensure that they are working properly before they are shipped out. If a motor had been assembled incorrectly, it would have been rejected and sent back for rework.