Even though we call two words "synonyms", it is rare for two words to mean EXACTLY the same thing. Words have "connotations" -- subtle differences in meaning.
An example of this that I remember from 30-something years ago: When I was in high school we saw a movie about industrial robots made by a Japanese company. They had some awkward points in translating the movie to English, but the funniest was the last sentence, when the narrator sums up by saying, "And thus, through the use of industrial robots, people can achieve happiness." The class burst into laughter, because we just don't use the word "happiness" in such a context. We use the word "happiness" for more personal things, like "Having a puppy makes me happy" or "Sally, if you marry me, you will make me the happiest man in the world!" If he had said, "Through the use of industrial robots, people have more pleasant lives" or "... enjoy their lives more", it would have sounded perfectly reasonable. By the dictionary definition of "happiness", the sentence probably sounded like exactly what the translator was trying to say. But it was just subtly wrong for that context.
The tough part is that there's no simple formula for this. It's not like I can say, "Always use the shorter word in informal contexts and the longer word in formal contexts", or "Always use the word with a 'b' sound when discussing business and the 'p' sound when discussing personal things" etc. You just have to learn the precise meaning and appropriate context of each word, and then choose the one most appropriate to what you are trying to say.
As a non-native speaker, you're not alone. Native speakers often have difficulty with this, too. The ability to choose exactly the right word is what makes the difference between great poets and orators and all the rest of us. I once read a humor article that took some famous quotes and re-worded them, so that by the dictionary, they'd mean essentially the same thing, but the alternate wording totally lost the punch. I recall one of them was Patrick Henry's quote, "These are the times that try men's souls", for which the writer offered the alternative wording, "Times like this are tough on people." Just not as memorable.