There was a misunderstanding here, maybe I described the pictures incorrectly.
"Box B" is in the bedroom, where Shelly is also installed and works as it should. The image is the original connection (before Shelly) and the marked wago contains a permanent phase.
"Box A" is in the hallway on another circuit, where I'm trying unsuccessfully to install Shelly. The picture shows the original connection and the marked wago does not contain a permanent phase (phase is on IN of switch). I don't know exactly what kind of wire it is when it's just finished. Apparently I mistakenly thought it led to light, but since there is only one, it's weird.
So both pictures are a place for Shelly and in both cases it's a 3-way connection.