Religious people believe in stuff like divine intervention or divine will. A communist would probably look at islam (my faith) and be like “No prophet was sent a message by God and acted upon it, it was their material conditions that made them act.” I don’t see how one could believe both, it feels like its either or.
You might be dealing with people who are mixing up mechanical materialism (see: https://en.prolewiki.org/wiki/Mechanical_materialism) with dialectical materialism.
I'm pretty sure a dialectical materialist view would say that somebody receiving a message from a god is part of their material conditions (if they did indeed receive such a message). From the other end of the belief, that they imagined the message somehow / that it was made up in some way, it might be more accurate to say the superstructure (beliefs level of things) is more of a driving factor in that, but either way, it's still a real thing impacting them.
We could put it in a context that's less charged with theological debate and belief for comparison: Suppose the president of the US were to text me directly and tell me that if I don't do X, they are going to do Y threatening thing to me. Is it likely the actual president texted me? No. But that doesn't make it totally impossible. Either way, if I believe that he did and if I believe that if I don't do X in response to his message, then Y is going to happen (that I perceive as bad), then I'm going to be pretty motivated to do X if Y is bad enough. Now maybe I ignore the text and Y never happens, and I assume I was scammed. Or maybe I ignore it and Y does happen, and now I'm terrified. With the first outcome, I probably don't change my behavior as a result. With the second, I probably do.
I don't know if I'm making the point clear, but basically what I'm trying get at is that dialectical and historical materialism is a process of understanding the world as we know it, but I don't think it is equipped to weigh in on whether deities exist (I'm open to correction if people believe otherwise). It can weigh in on religious systems, however, and what kind of impact it has when people believe in them and act upon that belief.
As to something like divine intervention, I don't think it's very practical (from a tactical point of view) for a communist to believe in it because you don't want to be in a situation where you are literally at war, struggling to survive, and instead of working out what weapons and tactics will win, you sit aside and pray to be saved. However, you could probably believe in divine intervention insofar as pray helping you win, as long as you aren't losing sight of tactics. And you might even be right in a sense, regardless of whether there is a deity who is willing to intervene on your behalf, in the sense that people believing in something beyond themselves and being collectively empowered as a result can be motivating and keep them strong in times of struggle.
Note that the point about prayer vs. action is even found in a well-known religious parable: https://en.wikipedia.org/wiki/Parable_of_the_drowning_man
The parable of the drowning man, also known as Two Boats and a Helicopter, is a short story, often told as a joke, most often about a devoutly Christian man, frequently a minister, who refuses several rescue attempts in the face of approaching floodwaters, each time telling the rescuers that God will save him. He finally drowns in the flood and, standing before God, asks why he was not saved. God replies that He sent the rescuers that the man turned down.
I would say, at the end of the day, it's less about religion itself and more about the form it takes. If the exploiting classes use X religion as part of their ruling power, you may have to forcibly change things about a particular religious institution in order to take power. If you are a believer in that particular religious institution, you might view it more as a theological fight over what is correct doctrine and practice. If you're secular, you might view it more as deposing manipulative religious power. Either way, the nature and form of political power has to be taken seriously. No matter what you believe, if you want to take power seriously, you have to take seriously what institutions are tangled up in it.
I hope that makes sense.