I don't see anything obviously wrong here, but a few suggestions/comments:
- I see that you check pixel data shape is the same between series, but do you know whether that guarantees they match spatially? The real-world pixel position and orientation (ImagePositionPatient, ImageOrientationPatient) should be checked also, as well as SliceLocation, perhaps others.
- not related to averaging, but SOPInstanceUID should be unique for each file you save
- I'd suggest creating a minimal working example - e.g. two series with only two images each, and stepping through the code with a debugger just before and after the averaging, inspecting the actual values, to narrow down the possible reasons the average is not what you expect.