The black spots when using the rear camera is caused by dust going inside the lens. You could try cleaning it out with something like a air compressor but you will be lucky if you are able to clean inside the lens.
You will need to replace the rear camera along with the rear camera glass at the same time to fix that issue.
S6 edge won't work on S6 as far as I know because they are slightly different in size to fit in.
When buying a rear camera make sure it is compatible with your model first.
You can either buy the mid frame which comes with the speaker or just the speaker itself meaning you will need to transfer the new speaker into the midframe.
Personally I would replace the whole midframe to be safe, also make sure that is for your model number of the phone as there are different variants for that too.
Here's iFixit guides if needed:
Reemplazo del medio marco del Samsung Galaxy S6
Samsung Galaxy S6 Rear Facing Camera Replacement
Sounds like there's some dirt or something in the lens. Clean it out, if that doesn't fix it then most likely will need a camera replacement.
- de Caitlyn
I fixed a similar problem in my Sony Z2 by removing the dust cap nearest the camera lens. This problem was a spec of dust either inside the lens or on the sensor. I then tapped the phone on my work bench. Then I blew into the slot. Turned the phone back on and the spot was gone. PS the lense maybe foggy for a minute or so as a result of the blowing but this quickly cleared.
- de timothy.trenning