Here are the specific canons:
Chapter IV : SPONSORS
Can. 872 In so far as possible, a person being baptised is to be assigned a sponsor. In the case of an adult baptism, the sponsor’s role is to assist the person in christian initiation.
In the case of an infant baptism, the role is together with the parents to present the child for baptism, and to help it to live a christian life befitting the baptised and faithfully to fulfil the duties inherent in baptism.
Can. 873 One sponsor, male or female, is sufficient; but there may be two, one of each sex.
Can. 874~1 To be admitted to undertake the office of sponsor, a person must:
1° be appointed by the candidate for baptism, or by the parents or whoever stands in their place, or failing these, by the parish priest or the minister; to be appointed the person must be suitable for this role and have the intention of fulfilling it;
2° be not less than sixteen years of age, unless a different age has been stipulated by the diocesan Bishop, or unless the parish priest or the minister considers that there is a just reason for an exception to be made;
3° be a catholic who has been confirmed and has received the blessed Eucharist, and who lives a life of faith which befits the role to be undertaken;
4° not labour under a canonical penalty, whether imposed or declared;
5° not be either the father or the mother of the person to be baptised.
~2 A baptised person who belongs to a non-catholic ecclesial community may be admitted only in company with a catholic sponsor, and then simply as a witness to the baptism.
For Confirmation:
Chapter IV : SPONSORS
Can. 892 As far as possible the person to be confirmed is to have a sponsor. The
sponsor’s function is to take care that the person confirmed behaves as a true witness of Christ and faithfully fulfils the duties inherent in this sacrament.
Can. 893~1 A person who would undertake the office of sponsor must fulfil the conditions mentioned in can. 874.
~2 It is desirable that the sponsor chosen be the one who undertook this role at baptism.
Concerning 874 #5
This includes Step-parents and adoptive parents, it does NOT exclude Grandparents.