If the contacts in iCloud.com do not match your iPhone and iPad, then the problem is between the iPhone/iPad and iCloud, not your Mac. Your Mac is simply reflecting the state of iCloud.com from the sound of things.
Isolate the point(s) of failure:
Focus on making sure every one of your devices is syncing to iCloud.com - that's the central point.
Create a new contact on iCloud.com - does it appear on your iPhone, your iPad, your Mac?
If it doesn't appear on your iPhone, you have a problem with the iPhone
If it doesn't appear on your iPad, you have a problem on your iPad
If it doesn't appear on your Mac, you have a problem on your Mac
Maybe you have a problem in more than one place.
Sometimes the problem is one-way, so in addition to creating that test contact on iCloud.com, create one on your iPhone, create another on your iPad, and another on your Mac (name each test contact differently, to keep track).
Do they all appear at iCloud.com? Again, if they don't, it tells you which device(s) have a problem.
Do not assume that a newly-created contact has been created in your iCloud account. Contacts can also be created /synced to other mail accounts (Gmail, Yahoo, AOL, Outlook, Exchange Server, etc.). So you need to check Settings > Contacts > Default Account on iPhone/iPad, and Contacts > Preferences > General > Default Account on Mac.
It's also possible that you're simply not viewing your iCloud contacts on one or more of your devices. On iPhone/iPad open the Contacts app and tap on Groups in the upper-left corner. Be sure there's a check-mark for iCloud. To be sure you're viewing only your iCloud contacts (to reduce confusion during troubleshooting), un-check any other contacts accounts. Similarly, in Mac Contacts be sure you're viewing the Groups sidebar (Contacts > View > Show/Hide Groups) and then click All iCloud in the Groups sidebar to view only iCloud.
There's more that can be said, but this methodology should point you in the right direction.