Fetch all categories from database

get_categories function will return an array of objects, each object a category.

You can read more about it here: https://developer.wordpress.org/reference/functions/get_categories/

Edit

And example, as Tim Malone mentioned in the comment there are examples on that page. But here is a simple one for you, that will display your categories in a list.

$categories = get_categories();

if($categories) :
echo "<ul>";
foreach ( $categories as $category ) {
    echo "<li><a href="".get_category_link( $category )."">".$category->name."</a></li>";
}
echo "</ul>";
endif;