In both examples you need a mask of the subject you want to do the gradient fill or stroke. How you get that mask is quite variable. The subject could have been green screened in capture or you can rotoscope them. In the case of animation the subject might already have a transparent background. Once you have a subject separated with a transparent background it can be transformed into a solid color mask (black or white).
Once you have a masking video of the subject...
In the first example you can create a gradient fill event on a track and set that track as a composite child to your mask track video. Then you typically choose Multiply (mask) blending mode on the masking track. The gradient will only show in the masked area.
In the second example, the "stroke" looks like a simple solid white fill of the mask. The first example had a gradient fill. That mask has an outline on the mask which can be done simply with the Layer Dimensionality effect. In this example the mask was enlarged to be bigger than the subject. The track order on this would be
The subject is on top of the white filled mask with outline.