Looking at the passage in MN 21:
Bhikkhus, even if bandits were to sever you savagely limb by limb with a two-handled saw, he who gave rise to a mind of hate towards them would not be carrying out my teaching. Herein, bhikkhus, you should train thus: ‘Our minds will remain unaffected, and we shall utter no evil words; we shall abide compassionate for their welfare, with a mind of loving-kindness, without inner hate. We shall abide pervading them with a mind imbued with loving-kindness; and starting with them, we shall abide pervading the all-encompassing world with a mind imbued with loving-kindness, abundant, exalted, immeasurable, without hostility and without ill will.’ That is how you should train, bhikkhus
..the Buddha told us not to have a "mind" of hatred. He didn't tell us to sit there doing nothing. So even in a hostile situation when one is under physical threat, the Buddha's teaching can still be very useful. A mind clouded with hatred would be very sluggish and clumsy, and won't be agile enough to react to get out of the situation safely. A mind free of hatred is very sharp and bright. One'd have a much better chance of making the right move to get out of the situation safely..