Hmm STM should automatically mask properly without needing to edit the mask comparison value in the material's inspector, but I'm glad that feature still works, at least. I wonder if that could be causing the problem...?
STM is meant to call Rebuild() upon OnEnable() already, so... I wonder if it's somehow getting the values incorrectly on the very first frame...? Maybe STM is being reactivated before the lower objects int he scripting order, causing it to ignore that...? Before I dig deeper into this, try setting STM's masking mode through the STM inspector itself. I wonder if that value could be getting confused somewhere. Look for the "maskMode" dropdown, and you should be able to select "Inside" or "Outside" and it should automatically do it's thing if placed inside a UI mask. (But not a RectMask2D yet, apparently) Please let me know how that goes!
Unfortunately, outline and dropshadow aren't currently supported via shaders in URP, since URP doesn't support multi-pass shaders for whatever reason. I'm still working on a proper solution, but until then I have this script which creates the same effect if attached to an STM object: https://pastebin.com/ixxVjtCH