Thank you for your comment, Kalleheikki Kannisto.
The stroke looks fine in illustrator both when it’s a path and when I expand it.
It’s how the masks work in AE: if you keep Illustrator out of the equation, and just go directly to AE and make a mask, the mask will be inverted in any area where the mask overlaps itself.
Hm :-\ Maybe it just not possible to set AE to not invert overlapping areas. It surprises me, that this is not a very commonly discussed issue, if the tutorial I’m following is a common way to make animated strokes…