It would seem that a heretic baptizing an infant (of say, Catholic parents) in danger of death is valid and the effect conferred if the correct matter and form is used. I would think the intention to "do what the Church does" is fulfilled here. In other cases, it is not as clear.
Eh, that's a contentious question, which is really why such situations should be avoided by any means possible.
Could the sacrament be coferred validly? Sure, I believe so. Does it necessarily follow that it would
always be conferred validly? I would say in the case of baptism, so long as either there was a compatible interior assent (i.e., the minister's theology held baptism to be salvific) or the minister had the sacerdotal charism, I would accept conference as being likely, or at least less than gravely doubtful. I would posit that the barrier of proper conference in the second quote of Thomas Aquinas has to do with the willful act of receiving sacraments from one formally in schism (in the case of receiving the Eucharist or an adult baptism). However, I would consider the case of an atheist or one denying original sin or the necessity of baptism, to be suspect in the conference of a baptism in the abstract. Of course, it seems to me unlikely that someone denying original sin or its remittance by baptism would bother, especially in an emergency setting, to baptise the child. If they did so, it would logically follow that they believed there was a
grave spiritual need to do so, and that the baptism fulfilled that need. It's probably a moot consideration.
If I'm not mistaken, weren't some converts from heretical sects NOT conditionally baptised when they converted?
Sure, conditional baptism is examined on a case-by-case basis, to determine if the form, matter and intent of the original minister was sufficient to confer the sacrament. For those baptised by a minister who possessed the intent properly formed by the theology of original sin and the laver of regeneration (Orthodox or other schismatics, Lutherans, Methodist, some Presbyterians, etc.), or have the sacerdotal charism necessary to correct the defect of faith by virtue of acting
in persona Christi, the baptism is probably going to be considered valid.