Spanish law says that self defense has to be justified (you did nothing to provoke the attack and you're in immediate danger), and proportional to the level of aggression. So she will probably be prosecuted.
No you see, having read that I think this meets all the criteria.
Did nothing to provoke the attack: she’s hardly likely to have invited rape?
In immediate danger: yes, immediate danger of being raped, proven by the fact his penis was close enough to get that she was able to cut it.
Proportional to the level of aggression: well she was being attacked with a penis so the proportionate response would be to disarm the penis so it could be used to attack her. Just like if he attacked her with a knife, she would try and get rid of the knife and no one would think that was disproportionate. Also, this wasn’t the first time he assaulted her so previous things she did to defend herself didn’t work and she knew this.