Only first shortcode gets executed

As indicated in the comments this code has nothing to do with shortcodes in the WordPress sense, but it is easy to see why it will never evaluate more than one pattern.

preg_match returns true if there is at least one instance of the needle found in the haystack. So, no matter how many “shortcodes” it finds, PHP will only execute the following code once, replacing one string with the other.