Well, yes and no. Many feature gods and priests, but that's not exactly the same thing. In fact, I'd go as far as to say that fantasy works which portray the gods of their world are less likely to involve actual religion than those which don't. Religion is a human institution, although one that's present in almost all cultures in one form or another — even societies that are militantly secular tend to replace religion with something parallel — whereas as soon as gods are portrayed as individuals who can be spoken to, their religious status tends to take a back seat to their status as characters. Religion is about belief and worship, not about whether you can share a drink in the pub with your god.
With the presence of priests, we should be on firmer footing. They are, after all, humans upholding a human institution, which is all very well as long as there's an institution for them to hold up. Many fantasy writers do portray the religions of their societies, but often priests will appear in isolation, usually performing unspeakable rites involving half-naked female victims which the hero is just in time to stop, but there's no sense of any religious infrastructure. The focus is on the evil god, who invariably makes an appearance, and the priest is simply a plot device to get the god to materialise.
Now, there's nothing wrong with any of this. I enjoy it as much as the next person when Conan or some similar hero battles with sinister, black-robed, shaven-headed priests of blasphemous gods. I enjoy reading about gods squabbling among themselves, or manifesting themselves in the mortal world. I've used these plot devices myself.
It's just that they're not religion.
The first fantasy writer to take the formal mythology approach (unless we count William Blake, whose pantheon was mainly meant to represent aspects of the human psyche) was Lord Dunsany, whose 1905 book The Gods of Pegana was less a collection of stories than a series of sketches of the various gods and goddesses of a fictional pantheon, worshipped in a secondary world. He did subsequently write stories about the lands in which those gods were worshipped, but seemed to lose interest in this and moved on to worlds that have complex relationships with ours.
Few authors went quite to this extent, although Tolkien's Valaquenta (included in The Silmarillion) is a similar work, but many invented gods for their characters to invoke — Conan always swears by Crom, for instance. Other early fantasy writers were content to reuse existing religions. Those who wrote alternative versions of mediaeval Europe, like William Morris, simply had a Christian background, while others used the Greek or Norse gods. James Branch Cabell went further, plundering Celtic, Russian and Indian mythology, among others.
More recent authors have often created impressive pantheons for their works, such as Moorcock's Lords of Law and Chaos, but it's less common (though by no means unknown) for the actual religions of those gods to be explored in fantasy. Tolkien, for instance, created a pantheon of lesser gods (or angelic powers, as he'd probably have preferred to call them) beneath Iluvatar, the One, but he shows no ritual or worship directed towards any of them, beyond occasional Elven songs in praise of Elbereth (whom some of them, of course, would have known her personally).
This probably wasn't an accident. Tolkien, a committed Christian, would have likely felt uncomfortable if his good characters had worshipped in anything other than a Christian manner, but his setting precluded Christian worship — just as he criticised Lewis for having Christmas in Narnia, which couldn't possibly have the same religious background as our world. Tolkien dealt with the issue by having no religion.
So what is religion? And what are the most usual forms of its manifestation?
As I said earlier, religion is first and foremost a human institution, consisting of rituals, laws and creeds whose essential purpose is to fulfil the spiritual needs and desires of ordinary people. Whether you believe that one (or more) of our real-world religions is literally true, or whether you believe with Marx that religion is the opium of the masses, is entirely up to you, and this piece isn't trying to convince you one way or another.
In practice, though, the nature of a religion is essentially the same, whether it's complete truth or complete fabrication. It's about people. A bunch of sinister priests skulking in a temple doesn't make a religion — that's made by the beliefs held by the mass of the people affected by it, and the ways in which it affects how they live their lives. Religion is a communal institution, not an elite one.
Broadly speaking, there are four types of religion: animistic, traditional, revealed and non-theistic. This, of course, is a gross simplification, and many religions fall between the cracks of these categories, but it's good enough for a general picture.
Animism, put very simply, is the belief that there are spirits everywhere, and they all need to be respected, appeased or defended against. An animist might need to placate the spirit of a tree he needs to fell or the animal he's hunting, or simply the spirit of a place where he wants to do anything. And some spirits may be malevolent, and so he needs protection against them.
Animism is usually fairly low on organisation, and it tends to be presented in fantasy among primitive tribes — the "noble savage" who lives in close accord with nature. There's some justification in this, but animism isn't necessarily simple. Indeed, it frequently makes far more demands than other religions on the individual, and far more complex ones. The systems of obligations and taboos arising from the Australian Dreamtime mythology, which is broadly animist, can be complex in the extreme.
A "traditional" religion (my term) is usually polytheistic, involving a pantheon of gods and rituals that have grown up organically over thousands of years. It's likely to have ultimately grown out of animism, but the big difference is that it features temples, priests and hierarchies, as well as probably more communal worship than animism. This kind of religion is usually seen (and presented in fantasy) in a very formalised way: you have the god of the sky, the god of war, the goddess of love and so on.
In fact, this tends to be a late rationalisation by poets of a very much more messy The Greek gods (the best-known example) actually all had numerous aspects, names and characteristics, many very different from the familiar ones. Aphrodite, for instance, is normally thought of as the goddess of love and beauty, but she was originally a sea goddess, an aspect which survived into the familiar story of her birth from the sea-foam.
It would be difficult for a fantasy writer to fully portray this in a secondary world, and most rationalised pantheons work well enough, but it would certainly give the religion a more realistic feel to make it a little less cut and dried, with conflicting cults in different regions and gods whose remits overlap. For a feeling of just how messy this can get in reality, try reading The Greek Myths by Robert Graves, which covers all the conflicting beliefs, besides suggesting their origins in cult and ritual.
Polytheistic traditional religions seem to have a way of evolving towards monotheism (whether or not they actually reach it) as the society grows more sophisticated. Judaism appears to have begun as polytheistic before evolving into henotheism, a belief in one god's superiority rather than uniqueness (Thou shalt have no other god before me, rather than Thou shalt not believe any other god exists). It appears to have reached a stage of full monotheism around the period of the Captivity in Babylon. It came into contact at this time with the Persian religion Zoroastrianism, which was evolving from a traditional religion into a dualistic system (Light against Dark), and it's reasonable to suppose they influenced each other.
At around the same time, the more intellectual among the Greeks were gradually relegating their mass of gods to the level of the Judaic angels (who themselves may have once been regarded as lesser gods) and setting up a single supreme being, although they didn't agree on its identity: Zeus, the One or the Demiurge. It would be interesting to tackle this tendency in a fantasy setting where a society with a traditional religion has reached the sophistication level of, say, classical Greece. In any case, realism suggests that a society's religion should have evolved over many centuries, whereas many fantasy religions seem to have been stuck since year zero.
Revealed or messianic religions, usually but not inevitably monotheistic, are those founded by a charismatic individual believed to have access to a deeper religious truth than others. This figure might be regarded as divine or as an inspired mortal prophet — of the two best-known examples in our world, one regards its messiah as god, the other considers that very idea blasphemous.
Revealed religions are likely to have at least as much structure, hierarchy and communal ritual as traditional religions, but they also tend to place a far greater emphasis on the individual, and particularly on individual morality. On the whole (and, again, this is a broad generalisation) traditional religions are more concerned with rules and taboos than with morals. This can be seen in Greek attitudes. Oedipus, for instance, wasn't punished because he'd sinned — his "sins" were, after all, committed in complete ignorance — but because he'd broken two fundamental taboos, and his motives for doing so were irrelevant. The Greeks didn't really start taking an interest in personal morality until the time of Socrates.
Revealed religion tends to be a lot more rare in fantasy than traditional religion, and when it does occur it's often portrayed in rather simple terms, as a crusade by a fanatical priest. The best-known example of a full portrayal (lying on the borders between SF and fantasy) is Frank Herbert's Dune series, although Shardik by Richard Adams also tackles this idea.
Most real-world religions are based around belief in one or more deities, although these figures can range from the supreme being of the universe to local tutelary spirits, but some treat gods largely as irrelevant — notably Buddhism, Taoism and Confucianism. Such non-theistic religions may evolve beliefs in beings that take the place of gods, such as the buddhas and bodhisattvas of Buddhism, or they may respect traditional gods side by side with their own teachings. They may also engage in communal rituals, but they're essentially about the moral and spiritual development of the individual, rather than about collective worship.
In some ways, this comes full circle from the animist position, in that both tend to concentrate on the individual's behaviour, but the similarity ends there, for the most part. Where animism, like traditional religions, is about placating beings in ways that might be entirely arbitrary, non-theistic religions generally regard the individual's behaviour as internally important, whether for their moral or spiritual development.
In the modern world, in particular, non-theistic structures often take the place of god-based religion for individuals or whole communities, whether the belief is in a state, an ideology or a sports team. It's unlikely that this kind of institution would loom very large in a more traditional secondary-world fantasy, since those kind of societies tend to still retain their more established religions, but the moral/spiritual-based style of religion could be used more.
First and foremost, religion tends to be seen not in its hierarchy and certainly not in its gods, but in the effect it has on people's characters and everyday lives. Their behaviour, and their reaction to the behaviour of others, will be informed by the rules of their religion, whether those rules are ritualised or morally based. The round of their lives will be affected by everything from religious duties to festivals and holy days to the very language they use. A society's religion permeates everything.
As I said at the beginning, I'm certainly not discouraging any fantasy writer from showing us their gods as people, or from having sinister priests skulking in corners and sacrificing virgins. But the world we're shown will be that much more realistic if we can see the religion itself, not just its trappings.