Because it was in Swedish waters?
... However, Sweden was a de facto German ally in WWII.
How did they then allow damaged allied bombers to land in Sweden?
Anyhow, this event happened already in Jan 1940, when Germany and Soviet Union were still "allied".
This S-2, like other type Stalinets subs, was even designed and built together by Germans and Russians for Soviet Union.