I want to know that why is damn considered a swear word while dang and darn are never considered swear words.
Your confusion likely comes from seeing all three of these words used as expletives. When someone is upset, they might say any of these three words, and yet Damn is considered very offensive, while the other two are considered less so. (Darn and Dang are still never used in formal English)
This is because Damn is considered a swear word in English, for historical and religious reasons (as SamBC mentioned earlier). When you want to say a swear word, but don't want to be offensive, people create "Minced Oaths". A minced oath is created by changing one or more sounds of the swear word, but not so much that a native speaker can't tell that it's been changed. The words are similar enough that the intent is conveyed without actually saying the offensive word in question.
English has many swear words. English has many MORE minced oaths in order to avoid saying the swear word. For any given swear word, there is likely at least one, if not dozens of minced oath versions of that swear word.
What makes a word a swear word? Culture. Typically religious taboos and gross violations of social norms. Swear words vary from language to language and culture to culture, and even within a single language you might find some regions consider a word more or less offensive than another region. (For instance, Cunt is considered extremely and excessively offensive in America, to the point where it's almost never used even by coarser types of people, while in England and Australia it might be considered a mild swear at worst, or even simply a casual word causing no offense outside of formal situations)
What makes a minced oath acceptable? The fact that it is not the original word. That said, be careful of your audience, as SOME groups and individuals consider some minced oaths to be as bad as the original swear. For example, if someone is offended by the use of Jesus as a swear, Jeebus (a minced version) may still be offensive, yet Jiminy Cricket (a slightly archaic minced version of the same) could be acceptable.
What makes a minced oath understandable? The fact that it sounds similar to the original word without sounding more similar to any other word. (This is why typically only native speakers can make new minced oaths... your working vocabulary has to be large enough to know that your minced oath isn't more similar to a different word instead)
Damn has religious connotations. It is wishing eternal suffering on someone (or, I suppose, something). Among people who consider casual blasphemy unacceptable, this is bad.
Darn is a method of repairing cloth, especially knitted cloth. As an expletive, it's a nonsense word with no meaning, thus not offensive.
Dang is nothing but a nonsense word with no meaning except that produced by its habitual use as an expletive. Thus is it not offensive.
Being a swear word isn't necessarily a binary condition. Expletives have varying degrees of vulgarity, and different words can fall into various places along that spectrum.
Someone might stub their toe, or forget their briefcase, and exclaim any of several words to express their frustration:
- Oh, fuck!
- Oh, shit!
- Oh, dammit!
- Oh, darn it!
- Oh, fiddlesticks!
Those are listed from most to least vulgar. The ones at the top would be more inappropriate in polite company, while the ones toward the bottom would be less offensive.
Learners should try to figure out which words are most likely to be perceived as rude or offensive, and do their best to avoid words that might offend, especially in situations where such language would be perceived as inappropriate (such as a classroom, a religious service, or a formal business meeting).