What is the purpose of a shomer for a groom either the day of or up to a week before the wedding?
Nitei Gavriel Nissuin vol 1, chapter 4 Halacha 5 says that the custom some have that the bride and groom don’t go around unaccompanied starts the shabbat before the wedding.
In footnote 12, he brings various opinions about when this starts. He quotes the Halichot Teiman that the practice starts a week before the wedding.
In the same footnote, he brings two reasons for the practice, one because the groom in likened to a king and a king does not go in public alone. Two, to protect the bride and groom from Mazikim.
Here is from Rav Aryeh Kaplan's Made in Heaven, Chapter 10, p.72
In some circles, the bridegroom does not go out alone during the week before the wedding (Eduth LeYisrael p. 6). In other circles, this is observed only on the day of the wedding, where both the bride and groom are given shomrim or "watchers" for the day (Bethrothed Forever p. 10).
Regarding the reason why there is a need for "guarding", he cites Chapter 26 p. 231 note 7, which discusses the week after the wedding. There, he cites Berachos 64b, Magen Avraham 239:7, and Mataamim HaChadash 56.
I'm not familiar with Eduth LeYisrael but my guess is it's a recent sefer. I'm not sure what Betrothed Forever says. I'm not sure what he wants from Berachos considering there is no 64b. Presumably he means 54b, which says the Chasan and Kallah need extra guarding. This is brought by Magen Avraham.
אלו צריכין שימור מהמזיקים חולה חי' חתן כלה אבל ות"ח בלילה
Mataamim HaChadash says that Berachos tells us that the Chasan and Kallah need extra guarding, which he says from witchcraft. He cites Targum Yonasan which says that the witchcraft that was done prevented the couple from consumating the marriage.
All of this refers to a Chosson, but it's debatable when he's called a Chosson. Presumably after the wedding but Rav Aryeh Kaplan is bringing (recent) sources which extend it to before the wedding.
Check here, footnotes 1-3, where it discusses some reasons for the custom. I believe that nowadays, we only get a shomer and shomeret for the day of the wedding, even though some of these sources would suggest further guarding is ideal.