The references to "When Marnie Was There" pertain mainly to the story of Anna, a young girl who temporarily moves to a coastal area (Norfolk in the original novel, or Hokkaido in the Studio Ghibli film adaptation) to recover her health. During her stay, Anna meets Marnie, a mysterious girl living in a large house by the marshes or seaside. The story unfolds over the course of this summer or temporary stay, during which Anna and Marnie develop a secretive and cherished friendship. So, "When Marnie was there" refers to the period during Anna's temporary stay in Norfolk (in the novel) or Hokkaido (in the film), which normally lasts through the summer. The story includes moments of discovery, bonding, mysteries about Marnie's identity, and ultimately closure about family ties.
In summary, Marnie was "there" during the time Anna was visiting the coastal area to recuperate, during a summer or a temporary relocation, leading to their deep relationship within that period.