How to exclude tags and categories from a function?

I don’t know how the structure of $cat_not_in looks like but make sure that that variable is not an array. If $cat_not_in is an array then you could try

if ($cat_not_in) {
  $args['category__not_in'] = $cat_not_in;
}
if ($tag_not_in) {
  $args['tag__not_in'] = $tag_not_in;
}

Also see WP Codex – WP_Query it allows for category exclusion by prefixing the category ID with a - (minus). Worth a try too. SO if your building your $cat_not_in array you could just prefix the IDs with - and then

if ($cat_not_in) {
  $args['cat'] = $cat_not_in;
}

Another approach completely might be to get a list of all category IDs into a $cat_get array and then iterate through the $cat_not_in array or string and pop the IDs you don’t want off the $cat_get array then you can use the same code as above like this

if ($cat_not_in) {
  $args['cat'] = $cat_get;
}