Are you adopting from a reputable shelter?
Some shelters have good intentions, but not good anything else.
Sounds like a bad case of coccidia, an intestinal virus, or loaded with worms.
Add the stress of whatever happened to the dog before it came to the shelter and then when you take it home. A lot to deal with.
I work for a veterinarian, I would start with collecting a stool sample and taking it in and having your vet run a fecal. This will tell them a lot about what is up with the dog. Collect some poo in a baggie and take it to your vet. Let them run the fecal and call you back with the findings. This will give you a starting place.
It may be a simple matter of some antibiotics, and a few days of a special diet.
I do some foster work, with strays we get, you can not believe the weird stuff I've run into.
My current foster, a Pembroke Welsh Corgi, had more issues than Playboy when I brought him home. After 2 months, he's made leaps and bounds! His problems were all behavioral. He was a psycho dog from ****.
Scared of everything, hadn't seen another dog in 4 years, food bowl possessive, chew bone possessive, angry, no manners. We have 3 dogs of our own. He is finally getting it. He really is a sweetie, but it has taken a TON of patience and calm, assertive correction to get him where he is now. I am at a point, where I am confident that we can now look for a home for him. A month ago, I would not have let him go, he was not ready.
Shelter dogs take patience, and it may cost some money, but in the end they can be worth it! You have to remember, there is most likely no history on the animal and it's previous treatment, and health problems can crop up.