It is a fundamental principle of evidence law that evidence of other bad acts is inadmissible. A defendant must be convicted on evidence he committed the crime charged. The judge screwed up.
I believe the "other bad acts" were admitted as evidence that the perp was busy sexting at the time of the crime and thus not paying attention to the child in the car.
You are correct, but most here can’t emotionally get past the horror of a dead baby. If prior bad acts were admissible generally, even a reformed felon would face a high risk of being convicted, not on the evidence presented on the crime being tried, but because he had committed one or more crimes in the past.