"He said to them, ‘When I sent you out without a purse, bag, or sandals, did you lack anything?’ They said, ‘No, not a thing.’ He said to them, ‘But now, the one who has a purse must take it, and likewise a bag. And the one who has no sword must sell his cloak and buy one. For I tell you, this scripture must be fulfilled in me, 'And he was counted among the lawless'; and indeed what is written about me is being fulfilled.’ They said, ‘Lord, look, here are two swords.’ He replied, ‘It is enough’" (Luke 22:35-38).
Jesus is not telling his disciples to attack anyone; that would indeed contradict the message of his entire ministry. But there's an important difference between attacking and protecting. He is telling his followers that the path ahead, of carrying the message of Truth, will not be easy and gentle. They will need to use the resources they've been given to remain firm in the face of severe opposition.