It doesn't happen all that often, but I've seen the AI do pretty much what you described on several occasions. They often stay to see how you deploy, but if there seems to be no good way to attack you advantageously, they'll leave the field of battle.
In your case, there must have been a sea link to their last province, which allowed a successful withdrawal.