Luke 22:35-38 And He said to them, “When I sent you out without money belt and bag and sandals, you did not lack anything, did you?” They said, “No, nothing.” And He said to them, “But now, whoever has a money belt is to take it along, likewise also a bag, and [whoever has no sword is to sell his coat and buy one. For I tell you that this which is written must be fulfilled in Me, ‘And He was numbered with transgressors’; for that which refers to Me has its fulfillment.” They said, “Lord, look, here are two swords.” And He said to them, “It is enough.”
Jesus explains why He said that in the same breath; it is so the prophecy would be fulfilled that He was among transgressors, Isaiah 53:12. Also what matters is the disciples actions. Jesus did not say what to do with the swords, He did not say to harm anyone. Therefore we can't read into the scripture something that's not there. Also shortly after when Peter did use the sword, Jesus rebuked him and said to put it away. There are numerous examples in the teachings and examples of Jesus and the disciples directly related to not retaliating or defending oneself or repaying evil with evil.