On many cars the front and rear washers use the same washer bottle and pump,and may share a filter ,often in the bottom of the washer bottle. When using the rear washer the switch reverses the polarity so the pump runs backwards. A one way valve reacts to the change of flow direction and diverts it to the rear of the car. The valve may be part of the pump rather than separate.
It could be as Jocko suggests a faulty electrical switch. So its worth checking the polarity going to the pump. It might indeed be reversed and the pump is actually running backwards. . But it might be that the pump/one way valve is clogged or faulty and sometimes allowing water to go where it shouldn't oughter .
I once had a similar problem on my Corsa. The washer bottle was clogged with slime. I managed to clear the filter by repeated flushing the bottle out using a hose pipe. I was then able to unclog the pump by using a length of pipe to alternately suck and blow water directly into the pump by lung power . If you try this be very careful not to get actual washer fluid into your mouth. Its noxious both from screenwash ingredients and possible algae growth. I avoided this by using a long enough length of clear pipe,that I could monitor it was only the fresh water I had filled the pipe with that could reach my mouth. Using a squeezy bottle of fluid might be a better alternative. Or a large syringe such as a turkey baster to alternately suck and blow water flow. But probably best to avoid using powerful air lines etc. I was also aided by the fact I couldnt disconnect the pipe at the pump end due to fancy connectors. But I found a pipe join near the wipers that was easy to disconnect and I reverse flushed through part of the cars pipework as well. In fact my first action was to blow the screen fluid remaining in the pipe down towards the pump. This action alone might have been enough to have unclogged the pump, especially if its just debris jamming the valve. And it may be an easy diy job that only takes seconds so nothing to lose by giving it a try first.
I did spend quite a long time doing the whole job . If you have to pay a mechanic it may be better to look for a good used replacements rather than spending time on a solution that may not work.