Yeah, the distinction is a bit fuzzy. I can come up with some examples, such as certain kinds of pumps that don't involve moving parts.
But when I think of things I call "motors" and "engines", I admit the distinction appears arbitrary (but clear nonetheless in my mind). For instance, if there's a device that moves things as a component of a larger machine, I'd call that device a "motor", but am likely to call the larger machine an "engine". And to go back to the pump, I'd call the device that moves to push the liquid a "motor", not an "engine", for no good reason.
As with much of English, this "rule" has enough exceptions as to question whether or not it should be called a "rule".
I put "rule" is scare quotes because what I was originally describing is decidedly not a rule at all, just a description of how I tend to use those words.