Eh the massacring happened on side streets, local Peking residents were trying to keep the army from moving into the square not really knowing that other Peking residents had already briefed the army on who the protesters actually were, and what they wanted, and how they behaved. Once the army was on the square and set an ultimatum it was cleared with no or few casualties, the reports are a bit fuzzy.
That doesn't excuse the CCP in one bit, of course, or rather it doesn't excuse the hardline faction who couldn't stomach that others in the party were actually talking to the protesters as that would set a precedent that you can just turn up on the square and get an audience with the party, or maybe more precisely could boost the influence of one party faction over the whole.
The whole situation really can't be divorced from Hu Yaobang and his role in the party: The protests were essentially a wake for him and his ideas. Which the hardliners thoroughly buried afterwards and the situation in China hasn't improved to the point where Chinese would even be comfortable to criticise that decision -- you'd get invited for tea, if you can catch on to the euphemism.
If it had been up to the hardliners yes the army would've massacred the whole square, if that hadn't been their intention they wouldn't have mischaracterised the nature of the protest towards the army. Without ordinary Peking citizens stepping in, and getting butchered for it, that massacre would have happened.
And yes the Uygur situation is a genocide that's without question or asterisk.