The back of your freewheel (cassette) is threaded and so is the motor (hub) and they screw in together. If crossthreaded, it wont go on all the way. Here's a picture I found on the web, it's not an ebike, but shows the threading. . You'll get the idea.
edit: I didnt explain cross threading. its...