YABVU. When someone doesn't have the mental capacity to make decisions regarding their health, obviously they have to be made for them. This includes matters of fertility.
Of course it's not nice for the lady in question to have to go through surgery and it's aftermath but it also wouldn't be nice for her to get pregnant again and lose the baby / have it taken into care.
The courts have had the power to order this kind of treatment for a very long time. It is not the start of some slippery slope.
You should hear what's been going on in the American Prison System re forced sterilisation. Much worse.