In the 1st sentence, to assign means to give a goal to the object.
In the 2nd one, it means to set.
Often, "assign" is used as in "assign a task/duty to someone". Here it's similar to allocate
Sometimes it's similar to "reserve for", like in "we assign large sums of money to travel budgets".