The short answer is no, it’s not a contradiction. The key is explicated in paragraph 1257 of the Catechism of the Catholic Church:
God has bound salvation to the sacrament of baptism, but he himself is not bound by his sacraments.
What this means is that the only ordinary means that the Church knows of by which a person is to be saved is the sacrament of baptism (CCC 1257). This is all that has been revealed to us (John 3:3-5). Therefore, those to whom this necessary means of salvation has been revealed are bound to use it.
But those who are not responsible for their ignorance of this revelation will not be held accountable:
This affirmation [the necessity to be baptized] is not aimed at those who, through no fault of their own, do not know Christ and his Church (CCC 847).
For these individuals, God administers the grace of salvation in ways known to him alone:
Although in ways known to himself God can lead those who, through no fault of their own, are ignorant of the Gospel, to that faith without which it is impossible to please him (CCC 848; cf. 1260).
Invincible ignorance, however, is not the only condition for salvation apart from the sacrament of baptism. The Church also teaches that such individuals must “seek God with a sincere heart, and, moved by grace, try in their actions to do his will as they know it through the dictates of their conscience” (CCC 847).
Despite the fact that non-baptized individuals who are not responsible for their ignorance can be saved (CCC 847), “the Church still has the obligation and also the sacred right to evangelize all men” (CCC 848).