Erasing content and settings will set back the iPhone to default, and remove everything that has been added before. If your contacts are still there, you did something else than erase the content.
Here's the right procedure once more:
On your iPhone, go to Settings - iCloud, and disable "Find my iPhone". You'll have to enter your iCloud ID's password, then it can be disabled.
That done, go to Settings (still your iPhone), and there, go to General - Reset. Select "Erase All Content And Settings". This will remove every information from the iPhone: Wi-Fi, Apple ID, email addresses, contacts, apps that have been added, ...