In an emergency where there is danger of imminent death, anyone (yes, anyone) who has the appropriate intention can baptize, by using the Trinitarian baptismal formula.
In all other cases, Catholics are instructed to contact their parish.
(Note that this only concerns who can baptize: not all persons should be baptized. There are certain restrictions regarding the baptism of certain adults, though young children can always be baptized.)
The official Catechism addresses this directly:
1256 The ordinary ministers of Baptism are the bishop and priest and, in the Latin Church, also the deacon. In case of necessity, anyone, even a non-baptized person, with the required intention, can baptize, 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.
To be very clear: in cases where there is danger of imminent death, anyone can baptize. A person does not need to be male or baptized. Even a child can baptize in an emergency, if an adult is not present or incapacitated, though the child must be able to form the appropriate intention.
When there is no danger of imminent death, baptism is to be handled by the Church. The relevant Canon law is:
THE MINISTER OF BAPTISM
Can. 861 §1. The ordinary minister of baptism is a bishop, a presbyter, or a deacon, without prejudice to the prescript of can. 530, n. 1.
Can. 530 The following functions are especially entrusted to a pastor:
1/ the administration of baptism; [...]
§2. When an ordinary minister is absent or impeded, a catechist or another person designated for this function by the local ordinary, or in a case of necessity any person with the right intention, confers baptism licitly. Pastors of souls, especially the pastor of a parish, are to be concerned that the Christian faithful are taught the correct way to baptize.
Can. 862 Except in a case of necessity, no one is permitted to confer baptism in the territory of another without the required permission, not even upon his own subjects.
Can. 863 The baptism of adults, at least of those who have completed their fourteenth year, is to be deferred to the diocesan bishop so that he himself administers it if he has judged it Expedient.
These rules are in place to ensure that the baptism is, above all, performed in a valid way, but also to ensure that it is recorded appropriately.
It would be unwise and prideful for a person to perform baptism out of accordance with these rules, for the same reason that it would be unwise and prideful for a person to perform life-threatening surgery without the proper consultation of a trained doctor. Though of course, when a person is dying in front of you and there is nobody better able, you will, can, and are obliged to do everything you can to help save them, if they can be saved.