Viruses can survive a format. A virus is like any other computer program that needs to execute. When you just reinstall Windows, then the virus was not deleted and can run after the reinstall.