Same category, not always the same yarn
The Craft Yarn Council groups worsted, afghan and aran yarns together as category 4, Medium. This is a range of yarn thicknesses, rather than one exact diameter or a fixed ply count.
Because the category is a range, one brand’s worsted can be a little thinner or thicker than another brand’s aran.
When you substitute one for the other
Compare the labels rather than the names: look at the yards or metres per 100 g and the recommended needle or hook size. Then knit or crochet a gauge swatch and check it with the stitch-gauge calculator before starting.