The coronation of King Joash required a carefully planned deployment of forces to ensure the young king's safety and to keep the uprising hidden. By splitting the guards and placing them at various locations, the organizers prevented any large, suspicious gatherings that might reveal their plans too early [ביאור שטיינזלץ].
The guards assigned to this mission consisted of men who had just completed their Sabbath shift. Because their replacements had already taken over, they were free from their regular duties and available for this special task [מצודת דוד]. One group of these off-duty guards was stationed at the king's house. Their specific job was to protect the king once he entered his home, making sure no enemies could gather to assassinate him [רש״י, מצודת דוד].
A second group of guards [רש״י] was positioned at the Foundation Gate, which is identified as the Eastern Gate [רד״ק, מצודת דוד]. It earned the name "Foundation" because it marked the starting point of the holy grounds, much like a foundation is the beginning of a building [מצודת דוד]. The parallel account in the Book of Kings refers to this same location as the Gate of Sur. The Jerusalem Talmud explains that this specific gate actually had seven different names [רש״י, רד״ק]. It was called Sur, meaning "depart," because lepers were purified there, echoing the biblical cry for the unclean to depart [רש״י].
The rest of the Israelites present, who were not part of these specific guard units, were assigned to stand watch in the courtyards of the House of God [מצודת דוד, ביאור שטיינזלץ].