How did Dio Brando survive the ship sinking?
Originally, Dio did die at the end of Phantom Blood, but when Araki decided to write Stardust Crusaders, he retconned the ending of Phantom Blood. These retcons were applied to the anime accordingly.

After retconning, the coffin had a second compartment that Dio hid in while Erina hid in the top compartment. After Erina got in the coffin, Dio ripped off Jonathan's head and got into the same coffin Erina was in. When Erina was rescued, they did not rescue the coffin, they let it sank, without knowing that Dio was within the second compartment.



However, an alternate explanation is provided in the novel Over Heaven, where Erina placed Dio and Jonathan's body along with herself in the coffin.  


  Chapter 79
  
  Dio knows that Nukesaku is falsely guiding the Joestar Group, buying
  time for Dio, who uses that time to write in his notebook. He tries to
  recall the last moments before ending up in the coffin, but his memory
  is hazy. Despite having surely entered the casket, Erina had survived
  with the child. Dio suspects that the four of them were in the same
  coffin, but Dio admits that he would never have shared the casket with
  someone. Yet he did lose consciousness, so who put him into the
  casket? Saving someone she hated would indeed be in accord with
  Erina's character. Dio is now sure that Erina took pity on him and
  pulled him into the casket to protect him, and put him to rest at the
  bottom of the ocean. Dio's memories become more and more hazy and he
  ends up confusing Erina with his own mother.