Set amount of fields on an existing content type
If I understand you correctly, you're trying to change the cardinality of a field based on user input. You can do this by using field_update_field():

$field_name = 'field_bar';
$field = field_info_field($field_name);

$field['cardinality'] = 10;  // Change to number you want

// field_update_field() throws an exception on failure
try {
  field_update_field($field);
}
catch (Exception $e) {
  drupal_set_message(t('Could not update field.'), 'error');
}


As you can see, cardinality is actually a per-field setting: if you wanted to do this on a per-instance basis (so, separate cardinality for the field for each content type/bundle), you actually need to create an entirely new field for each bundle.

This would likely cause a number of issues, particularly if you wanted to do things like display the values in a view (each field would be handled separately, even though the only thing different is the name and the cardinality).

Instead, what I'd do is just set the cardinality of the field you want to be dynamic to "unlimited" (FIELD_CARDINALITY_UNLIMITED in code): out of the box you get a fancy widget that lets users add as many values as they'd like.