The answer is that the hadith has been transmitted in two wordings: “women who visit graves” and “women who frequently visit graves.” If the latter wording is merely relational, there is no difficulty. But if it is an intensive form, then the wording “women who visit graves” provides an additional indication and must be accepted, since it applies even to a single visit.
The wording “women who frequently visit graves” generally denotes frequency. It is well known that when a warning is linked both to a single visit and to multiple visits, the wording linked to a single visit provides additional indication: according to the wording “women who visit graves,” the warning applies to one who visits even once, unlike the wording “women who frequently visit graves.” If we were to rely solely on “women who frequently visit graves,” we would be disregarding the implication of “women who visit graves.” Shaykh al-Islam, may Allah have mercy on him, discussed this issue well in Majmu' al-Fatawa (1), which the student of knowledge should review. He also mentioned several responses to those who maintain that visiting graves is recommended for women.
His statement, “And he says when he visits it”: the verb “he says” may be read with either a final nominative vowel or a final accusative vowel. If the conjunction is taken as introducing a new sentence, it is read in the nominative; but if it is taken as coordinated with “visiting,” it is read in the accusative, because when a present-tense verb is conjoined to a pure noun, it is put in the accusative through an implied “to.”
Ibn Malik said:
“When a verb is conjoined to a pure noun,
An implied or expressed ‘to’ puts it in the accusative.” (2)
As evidence for this, they cited the line:
“To wear a cloak and have my eye find comfort
Are dearer to me than wearing transparent garments.”
“Have my eye find comfort” is coordinated with “wearing,” which is a pure noun, namely a verbal noun.
“And he says when he visits it: …” Here, “and he says” is coordinated with “visiting,” so the meaning is: it is recommended that he say it. However, if it is read in the nominative, it is an independent sentence: “And he says, when he visits it or passes by it.”
His statement, “when he visits it,” means that he intends to visit it and sets out for it, or that he passes by it while intending to go elsewhere.
His statement, “Peace be upon you”: Peace is one of Allah’s Names, as in His saying, “He is Allah—there is no god but Him—the King, the Most Holy, the Source of Peace, the Granter of Security” [59:23]. Yet in the greeting, Allah’s Name is not what is intended; rather, what is meant is the wish for safety. It is a verbal noun, like “speech” in the sense of speaking. Thus, its meaning is: may safety be upon you—that is, a supplication that safety be granted to you.
For the inhabitants of the graves, safety means safety from punishment.