Because I was once shocked to learn how easily it is in some countries (like Portugal) for a woman to have the court force a man to submit to a paternity test [0].
I also heard (I guess a few decades ago) the courts would start automatically an investigation on their own when no man would recognise a child at birth.
- [0] https://www.tpalaw.pt/xms/files/BANGA_Site/Paternity_investi...
Intuitively it seems to me this is the most counterproductive law ever as living with this doubt is the best way to destroy a family.
Courts order paternity tests just fine though when there is a reasonable doubt.
The people concerned can always refuse to be tested though.