The question is overly broad and needs to be taken sacrament by sacrament. The question asked specifically about three sacraments: baptism, eucharist, and marriage.
The Catholic Church recognizes any baptism performed according to the church's teachings on baptism, no matter who performs it. From the Catechism of the Catholic Church:
V. WHO CAN BAPTIZE?
1256 The ordinary ministers of Baptism are the bishop and priest and,
in the Latin Church, also the deacon.57 In case of necessity, anyone,
even a non-baptized person, with the required intention, can baptize58
, by using the Trinitarian baptismal formula. The intention required
is to will to do what the Church does when she baptizes. The Church
finds the reason for this possibility in the universal saving will of
God and the necessity of Baptism for salvation.59
What makes a baptism invalid is 1) using something other than water to baptize, 2) using the wrong words (the baptism must use a trinitarian formula--be in the name of the Father, the Son and the Holy Spirit or Holy Ghost) and 3) intending to do anything other than a Christian baptism (for example, acting out a baptism as part of a theatrical production). If a non-Trinitarian person such as a Mormon attempts to perform a Christian baptism, it will be considered invalid or questionable because then they bring into doubt that they are intending to do as the church does.
In the case of the Eucharist, only a priest is empowered to enact the sacrament acting in the person of Christ the head (in persona Christi capitis) by virtue of his ordination. From the Catechism of the Catholic Church:
1369 The whole Church is united with the offering and intercession of
Christ. Since he has the ministry of Peter in the Church, the Pope is
associated with every celebration of the Eucharist, wherein he is
named as the sign and servant of the unity of the universal Church.
The bishop of the place is always responsible for the Eucharist, even
when a priest presides; the bishop's name is mentioned to signify his
presidency over the particular Church, in the midst of his
presbyterium and with the assistance of deacons. The community
intercedes also for all ministers who, for it and with it, offer the
Eucharistic sacrifice:
Let only that Eucharist be regarded as legitimate, which is celebrated
under [the presidency of] the bishop or him to whom he has
entrusted it.191
Through the ministry of priests the spiritual sacrifice of the faithful is
completed in union with the sacrifice of Christ the only Mediator, which in
the Eucharist is offered through the priests' hands in the name of the whole
Church in an unbloody and sacramental manner until the Lord himself comes.192
Also:
1410 It is Christ himself, the eternal high priest of the New Covenant
who, acting through the ministry of the priests, offers the
Eucharistic sacrifice. And it is the same Christ, really present under
the species of bread and wine, who is the offering of the Eucharistic
sacrifice.
1411 Only validly ordained priests can preside at the Eucharist and
consecrate the bread and the wine so that they become the Body and
Blood of the Lord.
The church also makes a distinction between valid sacraments (those conducted by persons with the power to do so, and according to the prescribed rites of the church) and licit sacraments (those valid sacraments which are legally permitted). At times the church will restrict the right of an ordained priest to conduct the sacraments for disciplinary reasons such as an interdict. At such times, if a sacrament is illicitly performed it is still recognized as valid. In other words, the pope disapproves for whatever reason, but God still provides the grace anyway. Anglicans and Orthodox have preserved an ordained apostolic priesthood but not communion with Rome, so in the absence of other impediments their eucharist is considered valid.
Eucharist also has implications on who can validly receive the sacrament since reception implies a certain level of unity of theology with the local bishop, and indirectly with the pope.
From the Catechism of the Catholic Church:
1399 The Eastern churches that are not in full communion with the
Catholic Church celebrate the Eucharist with great love. "These
Churches, although separated from us, yet possess true sacraments,
above all - by apostolic succession - the priesthood and the
Eucharist, whereby they are still joined to us in closest intimacy." A
certain communion in sacris, and so in the Eucharist, "given suitable
circumstances and the approval of Church authority, is not merely
possible but is encouraged."238
1400 Ecclesial communities derived from the Reformation and separated
from the Catholic Church, "have not preserved the proper reality of
the Eucharistic mystery in its fullness, especially because of the
absence of the sacrament of Holy Orders."239 It is for this reason
that, for the Catholic Church, Eucharistic intercommunion with these
communities is not possible. However these ecclesial communities,
"when they commemorate the Lord's death and resurrection in the Holy
Supper . . . profess that it signifies life in communion with Christ
and await his coming in glory."240
1401 When, in the Ordinary's judgment, a grave necessity arises,
Catholic ministers may give the sacraments of Eucharist, Penance, and
Anointing of the Sick to other Christians not in full communion with
the Catholic Church, who ask for them of their own will, provided they
give evidence of holding the Catholic faith regarding these sacraments
and possess the required dispositions.241
Marriages are generally valid no matter who officiates because in Catholic theology it is the husband and wife that administer the sacrament to each other. From the Catechism of the Catholic Church:
1623 According to Latin tradition, the spouses as ministers of
Christ's grace mutually confer upon each other the sacrament of
Matrimony by expressing their consent before the Church. In the
tradition of the Eastern Churches, the priests (bishops or presbyters)
are witnesses to the mutual consent given by the spouses,124 but for
the validity of the sacrament their blessing is also necessary.125