As I understand it, Protestants do not have a valid priesthood, and only priests can baptize unless there is a danger of death. Why, then, does the Catholic Church recognize Protestant baptism?
Since baptism is necessary for salvation and God wills the salvation of all, the Church recognizes all validly administered baptisms, even if Protestant. The Catechism of the Catholic Church states:
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. (CCC 1256)
When considering the validity of non-Catholic baptism, the Directory for the Application of Principles and Norms on Ecumenism instructs:
Baptism by immersion, or by pouring, together with the Trinitarian formula is, of itself, valid. Therefore, if the rituals, liturgical books, or established customs of a church or ecclesial community prescribe either of these ways of baptism, the sacrament is to be considered valid unless there are serious reasons for doubting that the minister has observed the regulations of his/her own community or church. (DE 95.a)