Some men feel betrayed if they find out they're not the biological father. But they don't have a right to terminate their obligations to the child. Courts want to protect children, so they generally stay away from disrupting the parent-child relationship, even if there is no biological basis. The courts justify their refusal to terminate the father's relationship because of the same factors that allowed them to establish his legal status a father in the first place.
Essentially, if he acted like a father, helped support and raise the child, then he's the child's father, at least until the child is emancipated, meaning, no longer legally entitled to support because of turning 18, or in some states, turning 21 or even 23. It's hard on the adult, but courts believe it's even harder on a child to lose a parent.
Anyone can become a father, even if they're not related to the child, and if that happens, they get the same rights to spend time with the child, and only the court change those rights.