So what is the problem?
There is no issue updating any item from the workflow. You can use workflowProperties.Item["FieldName"] = "Value" to update any field. The side effect is updating the item triggers the workflow again as it is configured to execute when item is modified. This causes the workflow to run in indefinite loop.
So what is the solution?
Create a new class within the workflow and inherit it with SPItemEventReceiver. Create two new functions called DisableWorkflow() and EnableWorkflow().
Inside DisableWorkflow() add a line –
this.DisableEventFiring
Inside EnableWorkflow() add a line –
this.EnableEventFiring
That’s it, just create a object of this class, call DisableWorkflow() just before workflowProperties.Item.Update() .Then call EnableWorkflow() after updating the item.