If the recipient desires to and receives the valid sacrament outside of the Church, the sacrament does it's part so far as removing Original sin, yet at the same time he commits a mortal sin. This is why conditional baptism is not an absolute requirement at all times for converts to the faith who've been baptized before entering the Church.
If one receives the sacrament for inheritance, marriage or some other reason without having a desire to receive it, I do not see that as being any different really than situation above.
When I'm talking about forced baptisms, I mean baptisms where there is zero consent. Take the example of Innocent III:
Denzinger 411
https://www.cathinfo.com/baptism-of-desire-and-feeneyism/the-catechism-of-the-council-of-trent-does-not-teach-baptism-of-desire/msg877636/#msg877636This is contrary to the Christian religion, that anyone always unwilling and interiorly objecting be compelled to receive and to observe Christianity. On this account some absurdly do not distinguish between unwilling and unwilling, and forced and forced, because he who is violently forced by terrors and punishments, and, lest he incur harm, receives the sacrament of baptism, such a one also as he who under pretense approaches baptism, receives the impressed sign of Christianity, and he himself, just as he willed conditionally although not absolutely, must be forced to the observance of Christian Faith. . . . But he who never consents, but inwardly contradicts, receives neither the matter nor the sign of the sacrament, because to contradict expressly is more than not to agree. . . . The sleeping, moreover, and the weak-minded, if before they incurred weak-mindedness, or before they went to sleep persisted in contradiction, because in these the idea of contradiction is understood to endure, although they have been so immersed, they do not receive the sign of the sacrament; not so, however, if they had first lived as catechumens and had the intention of being baptized; therefore, the Church has been accustomed to baptize such in a time of necessity. Thus, then the sacramental operation impresses the sign, when it does not meet the resisting obstacle of a contrary will.
The person who consents to avoid physical harm (or in your examples, to acquire an inheritance or marriage) = consents conditionally, and the sacrament is received
The person who does not consent at all = zero consent, and no sacrament is conferred
Infants have their God Parents do the desiring for them. Trent's catechism states that the Church decides for insane adults, but those who never expressed a desire to be baptized are not to be baptized at all, except in danger of death.
Yes, in regards to infants, I remember someone posting that on a different thread, but I was wondering about infants who have lost their parents, but if the Church can decide in the case for insane adults, so too can they decide in the case of infants who have lost their parents.