Information about your contacts is saved in your phone. In windows phones (or windows 10 mobile) there is an option to export that information to an SD Card for recovery purposes. However, those contact information are also stored in the cloud accessible through the Microsoft account you have used for your Windows Phone. After a hard reset, as long as you use the same Microsoft account, all your contacts will be synced back to your device.