(I am assuming that in the second case we are also not dealing with a danger of death situation. I also assume in both cases that the children are below the age of reason.)
As far as I can judge, in each of those cases, assuming that the correct matter and form were used and the person doing the work had the intention to baptize, it is valid, but illicit.
The bishop can authorize conditional baptism if and only if there remains a prudent doubt about fact or validity of baptism.
Although you are only asking about validity, I must add my own thoughts on why both of these are very bad ideas. After all, it would be horrible if my answer somehow inspired a grandparent to do something like this (and my comments will be especially directed toward grandparents).
First, to state the most obvious point, the question of validity is raised. It is not a good thing to have to even consider whether someone is or is not truly baptized. If Baptism is done by a priest in church with witnesses, there is an immensely greater likelihood (almost certainty) that there will be a valid Baptism celebrated. When a laywoman (who is not in the habit of baptizing) does something privately at home, she could easily say the wrong words, or make some other mistake a trained and practised priest would not only known not to do, but is formed by habit to not make those mistakes.
Second, liceity matters. If you are breaking the law of the Church, you are committing a sin. The fourth commandment tells us to honour father and mother. The Church is our mother. If you baptize an infant without authority to do so, you commit sin.
Third, your attempt to do something good for the child can backfire. When you are baptized Catholic, you become a citizen of the Church. And you are therefore bound by the laws of the Church. For example, you are bound by the marriage laws of the Church. So you may have baptized (for example) your grandchildren, but then those children grow up without a religious upbringing, have a wedding outside of canonical form, and are in invalid marriage (a marriage which would be valid if they were never baptized in the first place). And this is really bad, not because there aren’t remedies, but I know from pastoral experience that being in an irregular marital situation is one of the biggest obstacles to people becoming Catholic or returning to the Church. (There are other, more common ways in which sin could be increased, but I use this one because it is one most people would not think about. Suffice it to say that if you baptize your grandchildren, you place greater obligations on them even though you know they will not receive a religious upbringing to help them live out those obligations.)
Fourth, taking a more eschatological view of the situation, those who are baptized and are later lost to sin will suffer more than those who were never baptized. It is a sombre thought and I feel terrible even raising this possibility; but I also feel the need to disabuse people of the notion that they are doing something obviously good when they baptize their grandchildren illicitly. There are good reasons why the law of the Church says infants should only be baptized if there is a founded hope that they are raised in our religion.
Fourth, if the children are not going to have a religious upbringing as children, it might be better for grandparents to patiently wait until they are old enough to ask this for themselves. One of the benefits of Baptism is that it washes away not only sin but all the temporal punishment due to sin. Reconciliation does not get rid of all the temporal punishment and Baptism cannot be repeated. So, if they are not going to be raised in a religious household, but you evangelize them well, them may choose baptism as they get older and receive a remarkable cleansing of many years of sin they might not otherwise have had.