Religion is a belief in some powerful entity or entities' existence and necessity of obeying various rules and maintaining rituals to earn their benevolence or avoid their wrath.
The Goa'uld use their advanced technology to trick the uneducated into believing them to be actual gods, enslaving entire populations to worship them. Most Goa'uld either draw their act from, or were the inspiration for, various gods from Earth's past, especially those of ancient Egypt. Given the relative isolation of most worlds, those enslaved by the Goa'uld often continue in their belief long after being abandoned by their gods. Conversely, some cultures come to see the truth of the Goa'uld and drive them away, discarding the religion. (SG1: "Brief Candle", "New Ground", "Icon", "Memento")
The Asgard have also posed as gods, when dealing with more primitive societies whom they freed from Goa'uld domination, arguing that these societies are not yet ready to accept the truth of what the Asgard really are. Technology, most notably obelisks, are left on these planets for various purposes, such as a simple interactive hologram, and serve as a tangible substitute for the previously overthrown Goa'uld. Such worlds usually have a secondary obelisk which puts the people of that world through tests designed to judge whether or not they are ready to accept the truth. The Asgard base their illusion of gods on Norse mythology. (SG1: "Thor's Hammer", "Thor's Chariot", "Red Sky")
The ascended Ori created Origin as a means to garner the worship of regular humans, sapping their energy to make themselves stronger. Non-believers are considered heretics and destroyed. (SG1: "Origin")