In “Zayd came to me while his servant was riding”:
Circumstantial wāw marks the clause as describing accompanying circumstances.
-hu in ghulāmuhu refers to Zayd and links the two clauses.
The link prevents the second clause from being mistaken for an unrelated independent statement.