You’re probably not doing anything wrong. This sounds like a known macOS AppleScript bug that affects M1 Macs, which I’m told Apple has fixed in the forthcoming macOS 11.4. It the meantime, you may prefer to import using another method, e.g. by dragging and dropping Mail’s folders from Finder to EagleFiler, as described in Importing Mailbox Hierarchies.