The word Paul used in Galatians is different from that in Matthew:
O foolish (ἀνόητοι) Galatians! Who has bewitched you that you should not obey the truth, before whose eyes Jesus Christ was clearly portrayed among you as crucified? (Galatians 3:1 NKJV)
But I say to you that whoever is angry with his brother without a cause shall be in danger of the judgment. And whoever says to his brother, ‘Raca!’ shall be in danger of the council. But whoever says, ‘You fool! (Μωρέ)’ shall be in danger of hell fire. (Matthew 5:22 NKJV)
Therefore in the original language Paul did not ignore what Jesus taught. Μωρέ is transliterated "moros" and is where the English "moron" comes from.1
Some translations include subtitles within passages indicating what the translators believe is the main point of the passage. These additions like chapter and verse designations aid in locating passages. In Matthew, the NIV adds “Murder” and the New King James adds “Murder Begins in the Heart."
The context is that the Law goes much deeper than a literal “Do not murder.” Jesus is explaining that hatred, even if it is not acted upon is potentially as serious as murder.
Jesus continued and gave instruction. Rather than say to your brother "You moron" do this:
Therefore if you bring your gift to the altar, and there remember that your brother has something against you, leave your gift there before the altar, and go your way. First be reconciled to your brother, and then come and offer your gift. Agree with your adversary quickly, while you are on the way with him, lest your adversary deliver you to the judge, the judge hand you over to the officer, and you be thrown into prison. Assuredly, I say to you, you will by no means get out of there till you have paid the last penny. (Matthew 5:23-26 NKJV)
The use of the word creates the potential to be judged and a person is in danger of judgment. The best way to avoid the potential of an adverse ruling is to stay out of court. Also note the shift in the issue: what begins with "a cause" for the person (v22) is now "something against you" (v23). In other words the best way to avoid saying the wrong thing "without cause" is to take the initiative whenever someone has "something against you." Jesus is addressing the reality that disputes are rarely one-sided. Even if you have a cause you should not call your brother "moron" because your brother may have something against you.
Actual judgment is not based on what is said:
Brood of vipers! How can you, being evil, speak good things? For out of the abundance of the heart the mouth speaks. (Matthew 12:34 NKJV)
It is the heart not the use of the word on which judgment is made. Someone who is evil can say good things or avoid saying the wrong things; that does not make them good.
Paul did not use the same word but he did say something to get the attention of the Galatians who he felt were in danger of doing something foolish. This should be balanced against what Paul did teach:
Let no corrupt word proceed out of your mouth, but what is good for necessary edification, that it may impart grace to the hearers. And do not grieve the Holy Spirit of God, by whom you were sealed for the day of redemption. Let all bitterness, wrath, anger, clamor, and evil speaking be put away from you, with all malice. And be kind to one another, tenderhearted, forgiving one another, even as God in Christ forgave you. (Ephesians 4:29-32 NKJV)
Since the use of the word creates the potential for judgment, the prudent act is avoid calling names and take action to resolve all conflicts. Sometimes that is not possible as Jesus shows:
Fools (μωροὶ) and blind! For which is greater, the gold or the temple that sanctifies the gold? (Matthew 23:17 NKJV)
Jesus used a form of the same word when addressing the scribes and Pharisees who had been subjecting Him to tests in His House.
1 Some commentators note that the Greek Μωρέ is made up of the consonants which form the Hebrew מָרָה which is used to describe those rebelling against God (Numbers 20:10, Deuteronomy 1:26). If that reflects the meaning Jesus intended than it is more serious than the English “moron.”