There are several reasons religions are either taken over by dictatorships (e.g. Russia) or oppressed (e.g. communist states). When a dictatorship takes over a religion, it essentially tries to blend in with the religion and twist its principles to make it work with the dictatorship rhetoric. This is basically what is happening in Russia and most Islamic states. But the main reasons to do it remain the same.
Divide and conquer
One of the key elements for a dictatorship to survive is to ensure people do not band together against it. Religions offer a set of rules, traditions and principles to live by, which tends to bring people together, and creates trust between people. That's bad business for dictatorships, which want to ensure people do not trust each other enough to spark a revolution.
The idea of a creator / omniscient God
Most religions claim there's a God (or a group of gods) somewhere that is all knowing, all powerful, holds the keys to ultimate justice. Dictatorships want to hold those things for themselves. Religions essentially create an alternative to dictatorships. People will suddenly wonder if they should fear their maker or the dictatorship more. If they fear their maker more, and the teachings of the maker come in direct conflict with those of the dictatorship, then the dictatorship is potentially in trouble. This has been a source of friction e.g. between the Pope and various European emperors throughout the ages.
National identity
Religions often have some local traditions mixed in, which means the history of a nation is deeply intertwined with its religion. A dictatorship often wants to wipe the state clean and instill it own tradition in order to keep people obedient. This has been the approach of the soviet communism in USSR and satellite states.
Breeding ground for leaders
Prominent figures of religions will have popular support, and they can pose a threat to the current establishment of a dictatorship. This doesn't necessarily mean that they will overthrow the dictatorship rather than becoming part of it by replacing the current leadership, but this is a risk that the dictatorship system doesn't want to take. A good example would be Martin Luther and the protestant movement in the 16th and 17th centuries.
TL/DR:
Religions offer potentially dangerous alternatives to the dictatorship, so something has to be done about it.