There’s a difference between what *can *be done (valid) and what *should *be done (licit).
Baptism is always valid as long as someone uses water, the Trinitarian formula, and intends to do what the Church does in baptism.
However, baptism should normally be done by clergy in a church (canons 857 §1 and 861 §1). Only in cases where clergy are not available or there is a danger of death (can. 861 §2) should non-clergy baptize someone.
If a lay person baptized someone who was not in danger of death and they have access to clergy then the baptism is illicit but is still valid. In other words, it can be done but should not be done.