It isn't your job.
It isn't your job to know what to say. It isn't your job to fix a situation, and chances are, your words wouldn't have fixed anything anyways. Please stop kicking yourself because you can't find the right words, or are scared of "saying the wrong thing". In most situations, there isn't a wrong answer. You are trying your hardest to be there for them, and they know it. You're gonna mess up, stumble over words, and misinterpret things. That's okay. You're doing your best with the circumstances given, and that's more than enough.
People just want to be heard.
You know that cliche saying "you have two ears and one mouth for a reason"? Yeah, well, it's so true. People just want to know that they have someone to talk to. Be that person! There's nothing wrong with it. But when you listen, make sure you're listening to understand, not listening to respond. Focus on that person and what they're saying. Be engaged. Show them that you care. Sometimes, an ear to listen or a shoulder to cry on is more than enough. Unless you are physically God, everyone knows you're not going to have all the answers or solutions, so don't try to. Listen, and be there for those you care about.
Your words are more than enough.
I know you think everything you're saying is stupid and worthless. I know you think that you have nothing to contribute. I know you think that you're a bad friend because you sit in silence. But take those thoughts out of your head. Remember what I said about listening is more than enough? Well, that is definitely true. But at the same time, every single word that comes out of your mouth has value. Your thoughts, your ideas, your voice. All of it is so, so important. The world deserves to hear your thoughts, but for now let's save them for consoling a friend. Instead of trying to provide answers and solutions, try helping them understand their emotions or situations. Try making the smile, even the tiniest one. Instead of having those thoughts of being "useless" in any given situation, replace them with gratefulness that your friend chose you to confide in.
You are a great friend.
Your friend knows that you're busy. They know that you have so many friends and commitments. So they know what it means for you to be there for them. They know how much you care. Remember that. They know when you're being serious and when you're goofing off. They know that you get down to business. So they know you're trying. Remember that. Remember this the next time someone calls you, crying, or when you see your friend after a long day. Sit down, take the time, breathe, and listen. Remember that.