how do dogs and cats get mange. and how do you get rid of it.?

There are different kinds of mange. One kind is genetic and is caused when the dog is stressed and their immune system isn’t up to par. Some breeds are prone to it.
There is a contagious kind which can spread from dog to human or vice-versa and it is SCABIES. A Vet needs to treat this to be effective and to be sure you are treating the right kind of problem with the right product.
Another type of mite a dog can get is “chiggers” which they can get in forested areas. So if you have been camping, or have surroundings that are wooded or wild vined, then that is a possibility.