For Sweden, the rules in regard to temporary holding is also very clear. If the crime has a serious enough potential punishment and the investigation risk getting interference, or there is a significant flight risk, then the person under investigation is put in holding for as long as any of the above qualify. If Sweden ever get the same situation as the US and the government wanted to prevent family separation, what they would have to do is either write a special exception and override existing laws or change the punishment down to a fine.
Personally I don't find the law evil. The US implementation could use some major redesign in order to prioritize the child needs over that of the parents, but children should never end up in jail because their parents broke the law. The solution to the US issue must thus be in fixing so that immigrants don't break the law when they want to apply for asylum/legal immigration. That is what we did during the refugee crisis.
Man oh man, America "the shining beacon of freedom and democracy". "But what about the infants being torn away from their parents?" "Don't worry, the other side did it too, so we're not the bad guys here!"