The classic definition of a sacrament is that it's an outward sign instituted by Christ to give grace. "Instituted by Christ" is a curious phrase. It clearly does not mean that Jesus, in his lifetime on earth, listed seven and only seven actions that will forever be known as sacraments. In fact, Jesus never uses the word.
The definition derives from fifth-century Saint Augustine, who taught that a sacrament is "an outward and visible sign of an inward and invisible grace." He left out the part about where they came from. Third-century theologian Tertullian seems to have begun calling the initiating rituals of the church by the term sacramentum, which at the time was used for the oath of loyalty a Roman soldier vowed to the emperor. This Latin root word for sacrament means hidden or secret, similar to the Greek word for mystery.
Augustine advances the understanding of a sacrament by linking it to efficacy: that is, it effects what it signifies, does what it says. So baptism's waters bring death to sin and new life to us. Bread and wine become Christ's body and blood. However, Augustine fails to supply a definitive list of which actions do this. Nor does he limit sacraments to rituals but also includes objects. Across his writings, some 300 actions and elements are deemed signs of sacred realities; it's unclear that Augustine doesn't intend them all to be sacraments.
The church over time limits sacraments to ritual acts. Things—like holy water, ashes, palms—can be "sacramentals": elements that derive meaning from the sacraments. The Fourth Lateran Council in 1215 delineated the list of seven sacraments Catholics celebrate today.
In the New Testament, the ritual acts routinely practiced by the early church were baptism of new members and the breaking of the bread on the first day of the week. The Letter of James recommends anointing the sick, in imitation of Jesus who frequently touched those he healed. The practice of laying hands on those chosen for leadership is attested in the Acts of the Apostles. Both Jesus and Saint Paul rigorously support faithful marriages and forgiveness of sins in their teaching. Communicating the Holy Spirit as a seal of mature faith is also demonstrated by Jesus and later the apostles. Theologian Mark R. Francis implies that God "invents" sacraments as they exist to save us. It's the whole reason we have them—and the church.
Scriptures: Mark 1:9-10; 6:41-44; 8:23; 10:2-12; 14:22-24; Matthew 18:18; 19:1-9; 28:19; Luke 22:19-20; John 2:1-11; John 20:22-23; Acts 2:38, 41-42; 6:3-6; 8:14-17; 1 Corinthians 7:10-16; James 5:14-16
Books: Shape a Circle Ever Wider: Liturgical Inculturation in the United States - Mark R. Francis (Chicago: Liturgy Training Publications, 2007)
The Sacraments: Historical Foundations and Liturgical Theology - Kevin Irwin (Mahwah, NJ: Paulist Press, 2016)