Usually, a person needs to be of legal age in order to enter into a contract. In most states this is at least 18 years of age. This is referred to as the legal capacity to enter into a contract.
In addition to having legal capacity, a person also needs to have “competency” to form a contract. This is defined as: the ability to understand that a contract is being formed, and the ability to understand the general nature of the contract. So, even if a person has the legal capacity (age) to enter into a contract, a court might not enforce it if the person lacked the legal or mental capacity to do so.