This is what happened to me in the cup too. Based on the comments, my previous first choice GK had the ball and seemed to passed the ball to the closest opposing player who then scored. This was in the last minutes of the match. This is what made him lost his place. He was replaced as first choice GK, and later he was sold.
But, I think there is something fishy in all this. My newly bought scout GK apparently made almost the same mistake in the second leg of the same round of the cup. He made a save, and apparently there was a player near him who then scored from the save.
According to the comments, for both of the above cases, the time gap between the two events (GK has the ball and goal scored) was less than 1 second.
This is what indicated to me that the results of some matches have already been decided before the matches were actually played.