I'm actually a little dubious of the "never defeated" claim in the first place. Not only does it seem highly unlikely, but then there's this:
Khalid utilized his better understanding of terrain in every possible
way to gain strategic superiority over his enemies. During his Persian
campaigns, he initially never entered deep into Persian territory and
always kept the Arabian desert at his rear, allowing his forces to
retreat there in case of a defeat
That seems pretty unnecessary (and certainly not worth noting as a smart tactic) if he truly never suffered a rebuff. The more likely explanation is that he was using this tactic to stage ambushes, and then retreating once (if) the superior force organized itself.
Now in military terminology of course both sides like to claim victory if they can at all make a case for it. So what we have taken to doing in order to be somewhat objective about it is saying that the side that retains the field at the end of the engagement was the victor. Admittedly this means often the "victor" has suffered some manner of strategic setback, but that's how we term it.
In either case, any time a commander uses the tactic quoted above to effect a retreat, it is technically considered a "defeat" in the engagement. That doesn't mean its a dumb thing to do, but you can't say he's "undefeated".
I bring this up because history is full of commanders who were very successful overall, but in part because they knew when to retreat, and could do it in good order. In fact, its pretty much required. The counter-example is Pyrrhus, who is said to have "won" pretty much all his major battles against Rome (no retreats), yet lost his war.