This is a short fiction, probably a novelette. I read it not so many years ago (but still BC, I mean, before Covid) in a collection. But I think it was a very old collection.
The main character is a sentient, monstrous war machine. By construction, it is limited in its displacement (clearly a very wise precaution of its makers). It already went through a battle with enemies whom he destroyed, but was damaged in the battle. The worst damage is the receptor that was supposed to recognise a signal sent by people on "his side" to identify themselves. So when a party of "his side" comes after the battle to repair it, unable to recognise the signal, it attacks them. All are killed but one who manages to hide in a cave. From what follows it appears the survivor is the one who knows the machine best. Having no news of the first party, a second one comes to find out what happened. They carefully stay out of range of the machine's weapons and manage to communicate with the survivor. The latter has understood what went wrong and tells them to destroy the machine. But it is very expensive, and the second party tries to find another way. While they dither, the sentient machine, which is intelligent, finds a way (that his makers did not imagine) to extend the range of its weapons, or maybe to extend its own displacement limit, I forgot which. In that way it manages to destroy the second party who thought they were far enough to be safe. I am not sure if it finally kills the survivor of the first party, or if the latter dies of his wounds and/or exhaustion. But in the end the machine is alone.