It goes the otherway too. If a man has a child with a married woman, the husband is still the legal father and if the biological father waits to prove his is the father he may never gain any legal rights.
The laws are set up in the best interest of the child. It would be devestating for most children to have the only father they have known walk out on them. It can be equally devestating for them to have a stranger be declared their legal father and be forced in their life.