How do some parents get their kids back from foster care but others such as lose rights quickly after losing them for same/similar reasons?

How do some people who lose their kids to care due to addiction get them back (even after years) while others immediately lose parental rights? Or how do some lose rights to due to homelessness and others are in care temporarily until the parent gets public housing? Is it based on severity of the situation, what the kid requests, or time? I've heard of foster parents wanting to adopt kids who ended up going back to their parent who had repeatedly relapsed but other kids entered the system immediately able to be adopted because of their parents addiction. Have you experienced anything like this first hand?