Mouse is painting, stylus is erasing
Even though the poster was having a different problem, one of the answers to another question Painting problem when using pen in Blender seems to do the trick for me. If I change the Preferences &gt; Input &gt; Tablet &gt; Tablet API to Windows Ink then the stylus paints with the selected color.
I have no clue why this is happening though; I will accept any answer that sheds some more light on this issue.