These are flash messages which are typically triggered by controllers when saving or performing an action.
Craft::$app->getSession()->setFlash();
Craft::$app->getSession()->setError();
https://docs.craftcms.com/api/v3/craft-web-session.html#public-methods
Or in Craft CMS 3.5+ when used in a Controller action, you don't need to call the session service and can simply do.
$this->setSuccessFlash()
$this->setFailFlash()
In Twig this component is also available using:
{% do craft.app.session.setFlash() %}
{% do craft.app.session.setError() %}