In the good old days, a Press To Talk switch was used. All mics were disconnected by its switch at rest then when you press your switch to talk it connected your mic and disconnected your speaker.
Later, Voice Switching was used but it was messed up by noises like a person coughing, a motorcycle driving within a few miles away or a dog barking.
I worked with newer intercoms that used a digital echo canceller circuit that made a model of the room and its acoustics that cancelled feedback. It got messed up if something changed the room's acoustics like an open door or an added or missing person.