How can I get the content type for which a certain comment belongs? I have a comment type that's associated to various content types.

I have the comment entity but I want to get which content type(s) it belongs to.

How can I do that? Given that I can in the first place.
You can use Comment::getCommentedEntity() to get the entity, and if it's a node, grab the type:

$entity = $comment-&gt;getCommentedEntity();
if ($entity instanceof \Drupal\node\Entity\Node) {
  $type = $entity-&gt;getType();
}