Lost all my contacs

how did you have them saved? through Samsung backup? Google backup?
 
Go to contacts.google.com on your computer browser. Do you see your contacts there? (Make sure you're signed into your Google account on the browser.) If not, then at least we can say they weren't synced to your Google account.

If you entered all of the contacts into your phone using its "Phone Account," rather than your Google account or Samsung account, and you never manually backed up the contacts anywhere, then they're at risk for being completely lost if something happens to the phone. That's why it's always a good idea to sync your contacts to one of these clouds.
 
OK I found them. Now how to backup contacs and photos into Google account?
 
If the contacts weren't originally entered into your Google account, you'd have to export them as a .vcf file and then import them in to Google Contacts: https://support.google.com/contacts/answer/1069522?co=GENIE.Platform=Desktop&hl=en-GB

Here's how to back up your photos to Google Photos: https://support.google.com/photos/answer/6193313?co=GENIE.Platform=Android&hl=en. Make sure to set the quality to High Quality if you want unlimited backups. (Original Quality will count against your Google Drive space.)