If the priest is not a valid priest, would the marriages be valid?
Tricky question. As we know, the priest does not confer the Sacrament of Matrimony on the couple, but rather the couple confers it on each other, and the priest is merely there to witness the Sacrament for the Church, and to bless the union.
However, the Church has long required the presence of the local ordinary, the pastor, or a priest designated by them, or else the marriage is invalid. This is a requirement of canon law, and is not divinely required, as I understand it.
With that being said, there are a number of exceptions to this requirement, such as if there is a lack of priests. I'm not sure what the answer would be if the couple was married before a person claiming to be a priest, but in fact he was not.