"I cannot write this for you."
Translation:Nie mogę napisać tego za ciebie.
yes, in english "I can do this for you" could mean as a favor, or a service, or a gift for you, or it can mean instead of you, or in your place (so you don't have to do it yourself)... I think in spoken language the meaning would be more clear depending on which word you stress in the sentence "I can DO this for you" (as in, "I'm willing and able to do this for you) or I can do this FOR you; or the stress on "I" can do this for you (as in, so you don't have to do it, or "here, let me do it instead of/for you") and I guess in Polish they have two different words for the different meanings :)
Dla in the first context and za in the second.
I don't know much about the rules, I just feel the language, as it is my own - I'd say that it's perfective (in Polish we use the distinction dokonany/niedokonany, so kinda 'accomplished/not accomplished') is simply used because the interlocutor most probably wanted me to write the whole thing. "pisać" would focus on the process of writing.