Issue with iMessage on Mac

iMessage isn’t a “separate” or 3rd party application; it’s built into macOS.

You will have to reinstall macOS on top of your existing macOS installation to fix it as that will replace anything that you’ve removed.

Start from recovery by booting your Mac with the OptionR key combo held. That will boot you into a recovery version of macOS. Select only to “Reinstall macOS” on the existing disk that there. Don’t wipe it, partition the disk or anything. Simply install macOS as you normally would.

After you get macOS fixed, go back into iMessage and add back your iCloud account (remove it first if necessary). This will force iCloud to sync your iPhone’s and Mac’s messages once again.

In the future, if you lose the ability to sync messages, your first thing you should try is to log out of iCloud and log back in. Removing and reinstalling software is usually very low in the list of things to do to solve problems.