The court will not award custody and visitation rights to just any adult. That person must be a family member or parent and it is up to you to prove that you are one of those. For fathers, this is called establishing paternity. If you are married or were married to your ex-spouse when the child was born, then paternity is automatically established; you don't have to do anything else. But what happens if you weren't married? Do you have any recourse to getting parental rights and visitation?
In this scenario, you do. The easiest option is if you are present when the child was born and sign documents affirming that you are the father. The best way to accomplish this is to work with the mother. If the mother is cooperating, you can also work on establishing a parenting plan. A parenting plan essentially lays out how both parents are going to raise the child. It can be as detailed or broad as you prefer.
But if you are unable to agree with the mother or did not know she gave birth, then your options become more complicated. There are other ways to establish paternity like by compelling a DNA test, but it is much more complicated. You may want to speak to an attorney if you are in this situation.
Once paternity is established, you can try to get a custody arrangement. Assuming you are unable to agree with the other parent, then you can file for an order to establish visitation. The court will consider a variety of factors but the decision will primarily revolve around what is in the best interests of the child.
If you are trying to get visitation and custody rights over your child, you may want to speak to an attorney. These are complicated issues and an attorney will know the best ways to present your position to the court.