When fighting hostile mobs, it is imperative that you continuously hit them till they are dead to stop them from killing you. For example, when you encounter monsters like a zombie or spider.
When fighting a creeper, you should hit it and run backward to avoid being blown into pieces. This is called the hit and run strategy.
When you are up against a skeleton it would be useful to have a shield to avoid getting hit and in between the skeleton's shots, you should have a bow and arrow ready to shoot it. Do this over and over until the skeleton is dead.
Then last but not least a phantom. When you try to kill a phantom, it will continuously dive at you during this attack you can strike it, or you could try and shoot it from the air with a bow and arrow or crossbow, though I would prefer to hit it when it dives at you.