When someone is in a bad situation and you're in a better situation it can be hard to not feel sorry for that person or people.
It's not a bad thing to feel sorry for someone but the person may not like you feeling sorry for them however you can try to help the person you feel sorry for if they'll let you.
If possible do what you can to help them get into a better situation so you won't need to feel sorry for that person in that situation.
Most people do not like people feeling pity or feeling sorry for them so avoid telling the person you feel sorry for them in their situation.
Feeling sorry for someone or feeling pity for someone does mean that you have compassion though and shows you're a good person so it may not be possible to stop completely feeling sorry for someone.
But you can work on keeping it to yourself or like I mentioned above try to go out of your way to help that person without letting them know you're feeling sorry for them.