Each stream stores the `program_array_index` of its position in its program's `streams` array. When we remove a stream from this array, we need to correct the `program_array_index` of all streams that were backshifted by the removal. Also extract the removal into a new function and add some more safety checks. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2266>