Under what conditions is a battle a draw?

A draw is not possible in single player most of the time, only in multiplayer.

If the timer runs out in single player, the attacker loses the battle and must retreat. A settlement stays in the defenders hands.

The one exception is sallying out, due to the unique circumstance of the defender attacking and the attacker defending. If the timer runs out here, the battle ends in a draw, as the attacker doesn't want to retreat but hold up the siege, while the defender wants to keep the settlement. So, the status quo is maintained.

A multiplayer battle ends in a draw when the timer expires.