The HACK architecture support programs of up to 32768 words. A naive VM to CPU translator with no optimizations will produce larger ASM program. The VM Emulator doesn't have such limit, so your program can run there.
Optimization is an interesting and fun (if you're into that kind of thing) topic. But I advise you to leave it for after you've done with the hole course. After that you can go back and check
this post or search the forum for various discussions.