“Love toward oneself remains a fundamental principle of morality. Therefore it is legitimate to insist on respect for one's own right to life.” (CCC 2264)
The saying of Jesus: “Do not resist one who is evil. But if any one strikes you on the right cheek, turn to him the other also” (Matthew 5:39, RSV) is not an absolute. Like many things Jesus says, and that many other Bible writers say (particularly David and Solomon), this is a proverb, and admits of exceptions. They were never intended to be absolutely binding in every situation. It’s not teaching pacifism.
The same Jesus who said that we should turn our cheeks also said, “And let him who has no sword sell his mantle and buy one” (Luke 22:36). He also said, “all who take the sword will perish by the sword” (Matthew 26:52). It’s not a contradiction. It’s proverbial language: wisdom to be applied differently in different situations (see, for example, Proverbs 26:4-5).
Jesus didn’t totally turn the other cheek (or refuse to defend Himself) at His trial. He responded to Caiaphas the high priest:
Matthew 26:62-64 And the high priest stood up and said, “Have you no answer to make? What is it that these men testify against you?”  But Jesus was silent. And the high priest said to him, “I adjure you by the living God, tell us if you are the Christ, the Son of God.”  Jesus said to him, “You have said so. But I tell you, hereafter you will see the Son of man seated at the right hand of Power, and coming on the clouds of heaven.”
This hearkened back to Daniel 7:13: a well-known messianic prophecy (“behold, with the clouds of heaven there came one like a son of man”: RSV). This was the immediate cause of His being accused of blasphemy, leading to His execution, and they mocked Him as “Christ” (i.e., messiah) precisely because He had agreed that He was (26:65-68).
Jesus also replied to Pontius Pilate: “You would have no power over me unless it had been given you from above; therefore he who delivered me to you has the greater sin” (John 19:11). And He answered him earlier at some considerable length:
John 18:33-38 Pilate entered the praetorium again and called Jesus, and said to him, “Are you the King of the Jews?”  Jesus answered, “Do you say this of your own accord, or did others say it to you about me?”  Pilate answered, “Am I a Jew? Your own nation and the chief priests have handed you over to me; what have you done?”  Jesus answered, “My kingship is not of this world; if my kingship were of this world, my servants would fight, that I might not be handed over to the Jews; but my kingship is not from the world.”  Pilate said to him, “So you are a king?” Jesus answered, “You say that I am a king. For this I was born, and for this I have come into the world, to bear witness to the truth. Every one who is of the truth hears my voice.”  Pilate said to him, “What is truth?” . . .
And He answered “Annas . . . the father-in-law of Ca’iaphas, who was high priest” (Jn 18:13) at some length as well:
John 18:19-23 The high priest then questioned Jesus about his disciples and his teaching.  Jesus answered him, “I have spoken openly to the world; I have always taught in synagogues and in the temple, where all Jews come together; I have said nothing secretly.  Why do you ask me? Ask those who have heard me, what I said to them; they know what I said.”  When he had said this, one of the officers standing by struck Jesus with his hand, saying, “Is that how you answer the high priest?”  Jesus answered him, “If I have spoken wrongly, bear witness to the wrong; but if I have spoken rightly, why do you strike me?”
So he wasn’t “silent” at all. He actually said quite a bit during His trial, which is often brought up as an example of his “turning the other cheek.” He replied at length to three different people. It’s true, however, that He was silent during his Passion, as far as we know, excepting his seven sayings from the cross. And that is probably what the messianic prophecy of Isaiah 53:7 refers to (“he opened not his mouth”).
Another example I always give is St. Paul vigorously defending himself all through his trial, even appealing to his Roman citizenship (so he wouldn’t be crucified), and playing up his pharisaical training, so as to cleverly divide his accusers (Acts 16:37-38; 22:25-29 / “Pharisee”: Acts 23:6; 26:5; Phil 3:5).
Moreover, Jesus also stated that His disciples would be given words to say in the event of their martyrdom or false public accusations. They were not to remain absolutely silent (it’s assumed throughout that they would speak and bear witness to the truth):
Matthew 10:19-22 “When they deliver you up, do not be anxious how you are to speak or what you are to say; for what you are to say will be given to you in that hour;  for it is not you who speak, but the Spirit of your Father speaking through you.  Brother will deliver up brother to death, and the father his child, and children will rise against parents and have them put to death;  and you will be hated by all for my name’s sake. But he who endures to the end will be saved.”
Obviously, then, if neither our Lord Jesus nor St. Paul applied this saying as an absolute in all situations (and Paul tells us to imitate him: 2 Thess 3:7, 9 and many others), then neither should we. It’s certainly good advice in many situations, but not all. We have to use our best judgment and discernment and exercise prudence, as to when we should apply which method. We’re not forbidden from defending ourselves.