In CMS context you can get the component through the active application. The component may not necessarily support categories so it's a good idea to check if it implements the required interface:
$component = Joomla\CMS\Factory::getApplication()->bootComponent('content');
if (!$component instanceof Joomla\CMS\Categories\CategoryServiceInterface)
{
// Component does not support categories. Bail here.
}
$categories = $component->getCategory();
$cat = $categories->get($id);
return $cat->getChildren();