Some verbs, (known as ditransitive) have both a direct and an indirect object, which can be expressed either way round; but if the direct object comes first, the indirect requires its preposition "to":
I gave the book to him = I gave him the book.
In addition any verb which does not normally take an indirect object can have a benefactive complement introduced by "for", and in many cases this benefactive can come before the direct object in exactly the same way as for ditransitive verbs.
I made/baked him a cake = I made/baked a cake for him.
He bought me a book = He bought a book for me.
Keep me a seat! = Keep a seat for me.
I cut her a slice [of cake] = I cut a slice [of cake] for her.
I think there is a semantic restriction that the beneficiary is going to have, or use, or enjoy the result of the action, not just the action happening. So
Wash me a cup = Wash a cup for me (that I can use).
but I don't think I would say
?Wash me the laundry
even though I might say "Wash the laundry for me".