为 is similar to the preposition 给 , but 为 is more formal.
Pay attention
为 is most often used when talking about obligatory actions or duties.
For example, 为 is used when you need to say that someone works for an organization.
给 indicates that the action is done voluntarily,
and the person wants to benefit someone or provide a service.